github.com/git-lfs/git-lfs@v2.5.2+incompatible/t/t-post-commit.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  . "$(dirname "$0")/testlib.sh"
     4  
     5  begin_test "post-commit"
     6  (
     7    set -e
     8  
     9    reponame="$(basename "$0" ".sh")"
    10    setup_remote_repo "$reponame"
    11  
    12    clone_repo "$reponame" "$reponame"
    13  
    14    git lfs track --lockable "*.dat"
    15    git lfs track "*.big" # not lockable
    16    git add .gitattributes
    17    git commit -m "add git attributes"
    18  
    19    echo "Come with me" > pcfile1.dat
    20    echo "and you'll be" > pcfile2.dat
    21    echo "in a world" > pcfile3.big
    22    echo "of pure imagination" > pcfile4.big
    23  
    24    git add *.dat
    25    git commit -m "Committed large files"
    26  
    27    # New lockable files should have been made read-only now since not locked
    28    refute_file_writeable pcfile1.dat
    29    refute_file_writeable pcfile2.dat
    30    assert_file_writeable pcfile3.big
    31    assert_file_writeable pcfile4.big
    32  
    33    git push -u origin master
    34  
    35    # now lock files, then edit
    36    git lfs lock pcfile1.dat
    37    git lfs lock pcfile2.dat
    38  
    39    echo "Take a look" > pcfile1.dat
    40    echo "and you'll see" > pcfile2.dat
    41  
    42    git add pcfile1.dat pcfile2.dat
    43    git commit -m "Updated"
    44  
    45    # files should remain writeable since locked
    46    assert_file_writeable pcfile1.dat
    47    assert_file_writeable pcfile2.dat 
    48  
    49  )
    50  end_test
    51  
    52  begin_test "post-commit (locked file outside of LFS)"
    53  (
    54    set -e
    55  
    56    reponame="post-commit-external"
    57    setup_remote_repo "$reponame"
    58    clone_repo "$reponame" "$reponame"
    59  
    60    git lfs install
    61  
    62    # This step is intentionally done in two commits, due to a known bug bug in
    63    # the post-checkout process LFS performs. It compares changed files from HEAD,
    64    # which is an invalid previous state for the initial commit of a repository.
    65    echo "*.dat lockable" > .gitattributes
    66    git add .gitattributes
    67    git commit -m "initial commit"
    68  
    69    echo "hello" > a.dat
    70    git add a.dat
    71    assert_file_writeable a.dat
    72    git commit -m "add a.dat"
    73  
    74    refute_file_writeable a.dat
    75  )
    76  end_test