2015-07-30 02:37:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-05-26 22:08:03 +00:00
|
|
|
|
|
|
|
. "test/testlib.sh"
|
|
|
|
|
2015-06-27 15:19:00 +00:00
|
|
|
clean_setup () {
|
|
|
|
mkdir "$1"
|
|
|
|
cd "$1"
|
|
|
|
git init
|
|
|
|
}
|
2015-05-26 22:08:03 +00:00
|
|
|
|
2015-06-27 15:19:00 +00:00
|
|
|
begin_test "clean simple file"
|
2015-05-26 22:08:03 +00:00
|
|
|
(
|
|
|
|
set -e
|
2015-06-27 15:19:00 +00:00
|
|
|
clean_setup "simple"
|
2015-05-26 22:08:03 +00:00
|
|
|
|
|
|
|
echo "whatever" | git lfs clean | tee clean.log
|
2015-05-26 22:15:52 +00:00
|
|
|
[ "$(pointer cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411 9)" = "$(cat clean.log)" ]
|
2015-06-27 15:19:00 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "clean a pointer"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
clean_setup "pointer"
|
2015-05-26 22:08:03 +00:00
|
|
|
|
|
|
|
pointer cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411 9 | git lfs clean | tee clean.log
|
2015-05-26 22:15:52 +00:00
|
|
|
[ "$(pointer cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411 9)" = "$(cat clean.log)" ]
|
2015-06-27 15:19:00 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "clean pseudo pointer"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
clean_setup "pseudo"
|
2015-05-26 22:08:03 +00:00
|
|
|
|
|
|
|
echo "version https://git-lfs.github.com/spec/v1
|
|
|
|
oid sha256:7cd8be1d2cd0dd22cd9d229bb6b5785009a05e8b39d405615d882caac56562b5
|
|
|
|
size 1024
|
|
|
|
|
|
|
|
This is my test pointer. There are many like it, but this one is mine." | git lfs clean | tee clean.log
|
2015-05-26 22:15:52 +00:00
|
|
|
[ "$(pointer f492acbebb5faa22da4c1501c022af035469f624f426631f31936575873fefe1 202)" = "$(cat clean.log)" ]
|
2015-06-27 15:19:00 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "clean pseudo pointer with extra data"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
clean_setup "extra-data"
|
2015-05-26 22:08:03 +00:00
|
|
|
|
2015-06-27 15:19:00 +00:00
|
|
|
# pointer includes enough extra data to fill the 'git lfs clean' buffer
|
2015-07-23 01:06:38 +00:00
|
|
|
printf "version https://git-lfs.github.com/spec/v1
|
2015-05-26 22:08:03 +00:00
|
|
|
oid sha256:7cd8be1d2cd0dd22cd9d229bb6b5785009a05e8b39d405615d882caac56562b5
|
|
|
|
size 1024
|
|
|
|
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
|
2015-07-23 01:06:38 +00:00
|
|
|
This is my test pointer. There are many like it, but this one is mine.\n" | git lfs clean | tee clean.log
|
2015-05-26 22:15:52 +00:00
|
|
|
[ "$(pointer c2f909f6961bf85a92e2942ef3ed80c938a3d0ebaee6e72940692581052333be 586)" = "$(cat clean.log)" ]
|
2015-05-26 22:08:03 +00:00
|
|
|
)
|
|
|
|
end_test
|
2017-08-09 03:07:40 +00:00
|
|
|
|
|
|
|
begin_test "clean stdin"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# git-lfs-clean(1) writes to .git/lfs/objects, and therefore must be executed
|
|
|
|
# within a repository.
|
|
|
|
reponame="clean-over-stdin"
|
|
|
|
git init "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
|
|
|
|
base64 /dev/urandom | head -c 1024 > small.dat
|
|
|
|
base64 /dev/urandom | head -c 2048 > large.dat
|
|
|
|
|
|
|
|
expected_small="$(calc_oid_file "small.dat")"
|
|
|
|
expected_large="$(calc_oid_file "large.dat")"
|
|
|
|
|
|
|
|
actual_small="$(git lfs clean < "small.dat" | grep "oid" | cut -d ':' -f 2)"
|
|
|
|
actual_large="$(git lfs clean < "large.dat" | grep "oid" | cut -d ':' -f 2)"
|
|
|
|
|
|
|
|
if [ "$expected_small" != "$actual_small" ]; then
|
|
|
|
echo >&2 "fatal: expected small OID of: $expected_small, got: $actual_small"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$expected_large" != "$actual_large" ]; then
|
|
|
|
echo >&2 "fatal: expected large OID of: $expected_large, got: $actual_large"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
end_test
|