| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 4 | |
| 5 | begin_test "cleans only temp files and directories older than an hour" |
| 6 | ( |
| 7 | set -e |
| 8 | |
| 9 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")" |
| 10 | gitscip-shell system . . git. init "$reponame" |
| 11 | cd "$reponame" |
| 12 | |
| 13 | gitscip-shell system . . git. lfs track '*.bin' |
| 14 | echoscip-shell system . . echo. foo > abc.bin |
| 15 | gitscip-shell system . . git. add abc.bin |
| 16 | gitscip-shell system . . git. commit -m 'Add abc.bin' |
| 17 | |
| 18 | tmpdir=.git/lfs/tmp |
| 19 | mkdirscip-shell system . . mkdir. -p "$tmpdir" |
| 20 | |
| 21 | mkdirscip-shell system . . mkdir. "$tmpdir/dir-to-preserve" |
| 22 | touchscip-shell system . . touch. "$tmpdir/to-preserve" |
| 23 | touchscip-shell system . . touch. "$tmpdir/dir-to-preserve/file" |
| 24 | # git format-patch datestamp; arbitrary timestamp in the past. |
| 25 | TZ=UTC touchscip-shell system . . touch. -t 200109170000.00 "$tmpdir/to-destroy" |
| 26 | TZ=UTC touchscip-shell system . . touch. -t 200109170000.00 "$tmpdir/dir-to-preserve/file" |
| 27 | |
| 28 | gitscip-shell system . . git. lfs ls-files >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 29 | |
| 30 | [scip-shell system . . `[`. -f "$tmpdir/to-preserve" ] |
| 31 | [scip-shell system . . `[`. -f "$tmpdir/dir-to-preserve/file" ] |
| 32 | [scip-shell system . . `[`. ! -f "$tmpdir/to-destroy" ] |
| 33 | ) |
| 34 | end_test |