| 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 && exit 1 # 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 && exit 1 |
| 47 | grep "c.dat" new_files.log |
| 48 | grep "dir/d.dat" new_files.log && exit 1 |
| 49 | true |
| 50 | ) |
| 51 | end_test |
| 52 | |
| 53 | begin_test "track files using filename pattern with leading slash" |
| 54 | ( |
| 55 | set -e |
| 56 | |
| 57 | reponame="track-absolute-leading-slash" |
| 58 | mkdir -p "$reponame/dir" |
| 59 | cd $reponame |
| 60 | |
| 61 | git init |
| 62 | |
| 63 | # Adding files before being tracked by LFS |
| 64 | printf "contents" > a.dat |
| 65 | printf "contents" > dir/b.dat |
| 66 | |
| 67 | git add a.dat dir/b.dat |
| 68 | sleep 1 |
| 69 | git commit -m "initial commit" |
| 70 | |
| 71 | # These are added by git.GetTrackedFiles |
| 72 | git lfs track "/a.dat" | tee track.log |
| 73 | grep "Tracking \"/a.dat\"" track.log |
| 74 | git lfs track "/dir/b.dat" | tee track.log |
| 75 | grep "Tracking \"/dir/b.dat\"" track.log |
| 76 | |
| 77 | # These are added by Git's `clean` filter |
| 78 | git lfs track "/c.dat" | tee track.log |
| 79 | grep "Tracking \"/c.dat\"" track.log |
| 80 | git lfs track "/dir/d.dat" | tee track.log |
| 81 | grep "Tracking \"/dir/d.dat\"" track.log |
| 82 | |
| 83 | cat .gitattributes |
| 84 | |
| 85 | git add .gitattributes a.dat dir/b.dat |
| 86 | sleep 1 |
| 87 | git commit -m "convert to LFS" |
| 88 | |
| 89 | git lfs ls-files | tee files.log |
| 90 | |
| 91 | grep "a.dat" files.log |
| 92 | grep "dir/b.dat" files.log |
| 93 | |
| 94 | # Add files after being tracked by LFS |
| 95 | printf "contents" > c.dat |
| 96 | printf "contents" > dir/d.dat |
| 97 | |
| 98 | git add c.dat dir/d.dat |
| 99 | git commit -m "more lfs files" |
| 100 | |
| 101 | git lfs ls-files | tee new_files.log |
| 102 | |
| 103 | grep "a.dat" new_files.log |
| 104 | grep "dir/b.dat" new_files.log |
| 105 | grep "c.dat" new_files.log |
| 106 | grep "dir/d.dat" new_files.log |
| 107 | ) |
| 108 | end_test |