2015-05-18 19:44:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-05-18 22:49:21 +00:00
|
|
|
assert_pointer() {
|
|
|
|
local ref=$1
|
|
|
|
local path=$2
|
|
|
|
local oid=$3
|
|
|
|
local size=$4
|
|
|
|
|
|
|
|
gitblob=$(git ls-tree -l $ref | grep $path | cut -f 3 -d " ")
|
|
|
|
actual=$(git cat-file -p $gitblob)
|
|
|
|
expected=$(pointer $oid $size)
|
|
|
|
|
|
|
|
if [ "$expected" != "$actual" ]; then
|
|
|
|
exit 1
|
2015-05-18 19:44:22 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-05-18 22:49:21 +00:00
|
|
|
# no-op. check that the object does not exist in the git lfs server
|
|
|
|
refute_server_object() {
|
|
|
|
echo "refute server object: no-op"
|
|
|
|
}
|
|
|
|
|
|
|
|
# no-op. check that the object does exist in the git lfs server
|
|
|
|
assert_server_object() {
|
|
|
|
echo "assert server object: no-op"
|
|
|
|
}
|
|
|
|
|
|
|
|
pointer() {
|
|
|
|
local oid=$1
|
|
|
|
local size=$2
|
|
|
|
printf "version https://git-lfs.github.com/spec/v1
|
|
|
|
oid sha256:%s
|
|
|
|
size %s
|
|
|
|
" "$oid" "$size"
|
|
|
|
}
|
|
|
|
|
2015-05-18 19:44:22 +00:00
|
|
|
wait_for_file() {
|
|
|
|
local filename=$1
|
2015-05-18 19:58:58 +00:00
|
|
|
n=0
|
|
|
|
while [ $n -lt 10 ]; do
|
2015-05-18 19:44:22 +00:00
|
|
|
if [ -s $filename ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 0.5
|
2015-05-18 19:58:58 +00:00
|
|
|
n=`expr $n + 1`
|
2015-05-18 19:44:22 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_remote_repo() {
|
|
|
|
local reponame=$1
|
2015-05-18 22:49:21 +00:00
|
|
|
echo "set up remote git repository: $reponame"
|
2015-05-18 19:44:22 +00:00
|
|
|
repodir="$REMOTEDIR/$reponame.git"
|
2015-05-18 22:49:21 +00:00
|
|
|
mkdir -p "$repodir"
|
|
|
|
cd "$repodir"
|
2015-05-18 19:44:22 +00:00
|
|
|
git init --bare
|
|
|
|
git config http.receivepack true
|
|
|
|
git config receive.denyCurrentBranch ignore
|
|
|
|
|
2015-05-18 22:49:21 +00:00
|
|
|
# dump a simple git config file so clones use this test's Git LFS command
|
|
|
|
# and the custom credential helper
|
|
|
|
printf "[filter \"lfs\"]
|
|
|
|
required = true
|
|
|
|
smudge = %s smudge %%f
|
|
|
|
clean = %s clean %%f
|
|
|
|
[credential]
|
|
|
|
helper = %s
|
|
|
|
[remote \"origin\"]
|
|
|
|
url = %s/%s
|
|
|
|
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
|
|
" "$GITLFS" "$GITLFS" lfstest "$GITSERVER" "$reponame" > "$LFS_CONFIG-$reponame"
|
|
|
|
}
|
|
|
|
|
|
|
|
clone_repo() {
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
local reponame=$1
|
|
|
|
local dir=$2
|
|
|
|
echo "clone local git repository $reponame to $dir"
|
|
|
|
out=$(GIT_CONFIG="$LFS_CONFIG-$reponame" git clone "$GITSERVER/$reponame" "$dir" 2>&1)
|
|
|
|
cd "$dir"
|
|
|
|
|
|
|
|
git config credential.helper lfstest
|
|
|
|
echo "$out"
|
2015-05-18 19:44:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
2015-05-18 22:49:21 +00:00
|
|
|
cd "$ROOTDIR"
|
|
|
|
|
|
|
|
rm -rf "test/remote"
|
|
|
|
mkdir "test/remote"
|
|
|
|
|
2015-05-18 19:52:25 +00:00
|
|
|
echo "compile git-lfs for $0"
|
2015-05-18 19:44:22 +00:00
|
|
|
script/bootstrap
|
|
|
|
|
2015-05-18 22:49:21 +00:00
|
|
|
for go in test/cmd/*.go; do
|
|
|
|
go build -o "$BINPATH/$(basename $go .go)" "$go"
|
|
|
|
done
|
2015-05-18 19:44:22 +00:00
|
|
|
|
2015-05-18 22:49:21 +00:00
|
|
|
echo "LFSTEST_URL=$LFS_URL_FILE LFSTEST_DIR=$REMOTEDIR lfstest-gitserver"
|
2015-05-18 23:29:29 +00:00
|
|
|
LFSTEST_URL="$LFS_URL_FILE" LFSTEST_DIR="$REMOTEDIR" lfstest-gitserver > "$REMOTEDIR/gitserver.log" 2>&1 &
|
2015-05-18 22:49:21 +00:00
|
|
|
wait_for_file "$LFS_URL_FILE"
|
|
|
|
}
|
|
|
|
|
|
|
|
shutdown() {
|
2015-05-18 23:28:58 +00:00
|
|
|
rm -rf "$TRASHDIR"
|
2015-05-18 23:15:32 +00:00
|
|
|
|
2015-05-19 00:15:24 +00:00
|
|
|
if [ "$SHUTDOWN_LFS" = "no" ]; then
|
2015-05-18 23:15:32 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-05-18 23:57:43 +00:00
|
|
|
if [ -s "$LFS_URL_FILE" ]; then
|
|
|
|
curl "$(cat "$LFS_URL_FILE")/shutdown"
|
|
|
|
fi
|
2015-05-18 19:44:22 +00:00
|
|
|
}
|