2015-05-14 17:56:05 +00:00
|
|
|
#!/bin/sh
|
2015-05-19 22:54:15 +00:00
|
|
|
# This is a sample Git LFS test. See test/README.md and testhelpers.sh for
|
|
|
|
# more documentation.
|
2015-05-14 17:56:05 +00:00
|
|
|
|
2015-05-18 19:44:22 +00:00
|
|
|
. "test/testlib.sh"
|
2015-05-15 16:52:42 +00:00
|
|
|
|
2015-05-18 19:44:22 +00:00
|
|
|
begin_test "happy path"
|
|
|
|
(
|
|
|
|
set -e
|
2015-05-15 16:52:42 +00:00
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This initializes a new bare git repository in test/remote.
|
|
|
|
# These remote repositories are global to every test, so keep the names
|
|
|
|
# unique.
|
2015-05-18 23:28:58 +00:00
|
|
|
reponame="$(basename "$0" ".sh")"
|
2015-05-18 22:49:21 +00:00
|
|
|
setup_remote_repo "$reponame"
|
2015-05-15 16:52:42 +00:00
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# Clone the repository through the test Git server. It's cloned to
|
|
|
|
# $TRASHDIR/repo.
|
2015-05-18 22:49:21 +00:00
|
|
|
clone_repo "$reponame" repo
|
2015-05-14 17:56:05 +00:00
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This executes Git LFS from the local repo that was just cloned.
|
2015-05-18 19:44:22 +00:00
|
|
|
out=$($GITLFS track "*.dat" 2>&1)
|
2015-05-18 22:49:21 +00:00
|
|
|
echo "$out" | grep "Tracking \*.dat"
|
|
|
|
|
|
|
|
contents=$(printf "a")
|
|
|
|
contents_oid=$(printf "$contents" | shasum -a 256 | cut -f 1 -d " ")
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# Regular Git commands can be used.
|
2015-05-18 22:49:21 +00:00
|
|
|
printf "$contents" > a.dat
|
|
|
|
git add a.dat
|
|
|
|
git add .gitattributes
|
|
|
|
out=$(git commit -m "add a.dat" 2>&1)
|
|
|
|
echo "$out" | grep "master (root-commit)"
|
|
|
|
echo "$out" | grep "2 files changed"
|
|
|
|
echo "$out" | grep "create mode 100644 a.dat"
|
|
|
|
echo "$out" | grep "create mode 100644 .gitattributes"
|
|
|
|
|
|
|
|
out=$(cat a.dat)
|
|
|
|
if [ "$out" != "a" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This is a small shell function that runs several git commands together.
|
2015-05-18 22:49:21 +00:00
|
|
|
assert_pointer "master" "a.dat" "$contents_oid" 1
|
|
|
|
|
|
|
|
refute_server_object "$contents_oid"
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This pushes to the remote repository set up at the top of the test.
|
2015-05-18 22:49:21 +00:00
|
|
|
out=$(git push origin master 2>&1)
|
|
|
|
echo "$out" | grep "(1 of 1 files) 1 B / 1 B 100.00 %"
|
|
|
|
echo "$out" | grep "master -> master"
|
|
|
|
|
|
|
|
assert_server_object "$contents_oid" "$contents"
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This clones the repository to another subdirectory of $TRASHDIR
|
2015-05-18 22:49:21 +00:00
|
|
|
out=$(clone_repo "$reponame" clone)
|
|
|
|
echo "$out" | grep "Cloning into 'clone'"
|
|
|
|
echo "$out" | grep "Downloading a.dat (1 B)"
|
|
|
|
|
|
|
|
out=$(cat a.dat)
|
|
|
|
if [ "$out" != "a" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
assert_pointer "master" "a.dat" "$contents_oid" 1
|
2015-05-18 19:44:22 +00:00
|
|
|
)
|
|
|
|
end_test
|