github.com/x-oss-byte/git-lfs@v2.5.2+incompatible/t/t-track-wildcards.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  . "$(dirname "$0")/testlib.sh"
     4  
     5  begin_test "track files using wildcard pattern with leading slash"
     6  (
     7    set -e
     8  
     9    reponame="track-wildcard-leading-slash"
    10    mkdir -p "$reponame/dir"
    11    cd $reponame
    12  
    13    git init
    14  
    15    # Adding files before being tracked by LFS
    16    printf "contents" > a.dat
    17    printf "contents" > dir/b.dat
    18  
    19    git add a.dat dir/b.dat
    20    git commit -m "initial commit"
    21  
    22    # Track only in the root
    23    git lfs track "/*.dat"
    24    grep "/*.dat" .gitattributes
    25  
    26    git add .gitattributes a.dat dir/b.dat
    27    sleep 1
    28    git commit -m "convert to LFS"
    29  
    30    git lfs ls-files | tee files.log
    31  
    32    grep "a.dat" files.log
    33    [ ! $(grep "dir/b.dat" files.log) ] # Subdirectories ignored
    34  
    35    # Add files after being tracked by LFS
    36    printf "contents" > c.dat
    37    printf "contents" > dir/d.dat
    38  
    39    git add c.dat dir/d.dat
    40    sleep 1
    41    git commit -m "more lfs files"
    42  
    43    git lfs ls-files | tee new_files.log
    44  
    45    grep "a.dat" new_files.log
    46    [ ! $(grep "dir/b.dat" new_files.log) ]
    47    grep "c.dat" new_files.log
    48    [ ! $(grep "dir/d.dat" new_files.log) ]
    49  )
    50  end_test
    51  
    52  begin_test "track files using filename pattern with leading slash"
    53  (
    54    set -e
    55  
    56    reponame="track-absolute-leading-slash"
    57    mkdir -p "$reponame/dir"
    58    cd $reponame
    59  
    60    git init
    61  
    62    # Adding files before being tracked by LFS
    63    printf "contents" > a.dat
    64    printf "contents" > dir/b.dat
    65  
    66    git add a.dat dir/b.dat
    67    sleep 1
    68    git commit -m "initial commit"
    69  
    70    # These are added by git.GetTrackedFiles
    71    git lfs track "/a.dat" | tee track.log
    72    grep "Tracking \"/a.dat\"" track.log
    73    git lfs track "/dir/b.dat" | tee track.log
    74    grep "Tracking \"/dir/b.dat\"" track.log
    75  
    76    # These are added by Git's `clean` filter
    77    git lfs track "/c.dat" | tee track.log
    78    grep "Tracking \"/c.dat\"" track.log
    79    git lfs track "/dir/d.dat" | tee track.log
    80    grep "Tracking \"/dir/d.dat\"" track.log
    81  
    82    cat .gitattributes
    83  
    84    git add .gitattributes a.dat dir/b.dat
    85    sleep 1
    86    git commit -m "convert to LFS"
    87  
    88    git lfs ls-files | tee files.log
    89  
    90    grep "a.dat" files.log
    91    grep "dir/b.dat" files.log
    92  
    93    # Add files after being tracked by LFS
    94    printf "contents" > c.dat
    95    printf "contents" > dir/d.dat
    96  
    97    git add c.dat dir/d.dat
    98    git commit -m "more lfs files"
    99  
   100    git lfs ls-files | tee new_files.log
   101  
   102    grep "a.dat" new_files.log
   103    grep "dir/b.dat" new_files.log
   104    grep "c.dat" new_files.log
   105    grep "dir/d.dat" new_files.log
   106  )
   107  end_test