2016-06-03 23:24:38 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-12-07 01:08:18 +00:00
|
|
|
begin_test "list a single lock with bad ref"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="locks-list-other-branch-required"
|
2018-01-05 21:25:50 +00:00
|
|
|
setup_remote_repo "$reponame"
|
2017-12-07 01:08:18 +00:00
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
2018-01-05 21:25:50 +00:00
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "f" > f.dat
|
|
|
|
git add .gitattributes f.dat
|
|
|
|
git commit -m "add f.dat"
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main:other
|
2018-01-05 21:25:50 +00:00
|
|
|
|
2017-12-07 01:08:18 +00:00
|
|
|
git checkout -b other
|
|
|
|
git lfs lock --json "f.dat" | tee lock.log
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2017-12-07 01:08:18 +00:00
|
|
|
git lfs locks --path "f.dat" 2>&1 | tee locks.log
|
|
|
|
if [ "0" -eq "${PIPESTATUS[0]}" ]; then
|
|
|
|
echo >&2 "fatal: expected 'git lfs lock \'a.dat\'' to fail"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
grep 'Expected ref "refs/heads/other", got "refs/heads/main"' locks.log
|
2017-12-07 01:08:18 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-06-03 23:24:38 +00:00
|
|
|
begin_test "list a single lock"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
reponame="locks-list-main-branch-required"
|
2016-12-28 23:22:47 +00:00
|
|
|
setup_remote_repo_with_file "$reponame" "f.dat"
|
2017-12-07 01:08:18 +00:00
|
|
|
clone_repo "$reponame" "$reponame"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "f.dat" | tee lock.log
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
id=$(assert_lock lock.log f.dat)
|
2020-06-29 16:18:57 +00:00
|
|
|
assert_server_lock "$reponame" "$id" "refs/heads/main"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --path "f.dat" | tee locks.log
|
2017-02-23 20:02:42 +00:00
|
|
|
[ $(wc -l < locks.log) -eq 1 ]
|
2016-06-03 23:24:38 +00:00
|
|
|
grep "f.dat" locks.log
|
2017-02-03 17:48:31 +00:00
|
|
|
grep "Git LFS Tests" locks.log
|
2016-06-03 23:24:38 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2021-05-14 19:23:14 +00:00
|
|
|
begin_test "list a single lock (SSH; git-lfs-authenticate)"
|
2019-07-17 20:33:59 +00:00
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="locks-list-ssh"
|
|
|
|
setup_remote_repo_with_file "$reponame" "f.dat"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
sshurl="${GITSERVER/http:\/\//ssh://git@}/$reponame"
|
|
|
|
git config lfs.url "$sshurl"
|
|
|
|
|
|
|
|
git lfs lock --json "f.dat" | tee lock.log
|
|
|
|
|
|
|
|
id=$(assert_lock lock.log f.dat)
|
2020-06-29 16:18:57 +00:00
|
|
|
assert_server_lock "$reponame" "$id" "refs/heads/main"
|
2019-07-17 20:33:59 +00:00
|
|
|
|
|
|
|
GIT_TRACE=1 git lfs locks --path "f.dat" 2>trace.log | tee locks.log
|
|
|
|
cat trace.log
|
|
|
|
[ $(wc -l < locks.log) -eq 1 ]
|
|
|
|
grep "f.dat" locks.log
|
|
|
|
grep "Git LFS Tests" locks.log
|
lfshttp: don't strip off initial slash on SSH commands
When we process an SSH URL, we intentionally strip off the slash at the
beginning of the URL. While that was convenient for
git-lfs-authenticate, it also prevents us from handling an absolute path
in git-lfs-transfer, since the path will have its leading slash stripped
off and will therefore be relative.
Instead, let's adopt Git's behavior, which is to not remove the leading
slash. This is an incompatible change, but we're about to do a major
release, so it's a good time to make it. This will affect both
git-lfs-transfer and git-lfs-authenticate commands, but at least GitHub
already supports the proper syntax.
Note that since we process the non-URL form of SSH remotes by converting
them to a URL and then parsing, let's strip off the leading slash when
we process that form, since there we do have the ability to distinguish
between absolute and relative paths.
Update the lfs-ssh-echo binary to handle this new format.
2021-05-14 18:00:23 +00:00
|
|
|
grep "lfs-ssh-echo.*git-lfs-authenticate /$reponame download" trace.log
|
2019-07-17 20:33:59 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2021-05-14 19:23:14 +00:00
|
|
|
begin_test "list a single lock (SSH; git-lfs-transfer)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
setup_pure_ssh
|
|
|
|
|
|
|
|
reponame="locks-list-ssh-pure"
|
|
|
|
setup_remote_repo_with_file "$reponame" "f.dat"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
sshurl=$(ssh_remote "$reponame")
|
|
|
|
git config lfs.url "$sshurl"
|
|
|
|
|
|
|
|
GIT_TRACE_PACKET=1 git lfs lock --json "f.dat" | tee lock.log
|
|
|
|
|
|
|
|
id=$(assert_lock lock.log f.dat)
|
|
|
|
assert_server_lock_ssh "$reponame" "$id" "refs/heads/main"
|
|
|
|
|
|
|
|
GIT_TRACE=1 git lfs locks --path "f.dat" 2>trace.log | tee locks.log
|
|
|
|
cat trace.log
|
|
|
|
[ $(wc -l < locks.log) -eq 1 ]
|
|
|
|
grep "f.dat" locks.log
|
|
|
|
grep "lfs-ssh-echo.*git-lfs-transfer .*$reponame.git download" trace.log
|
|
|
|
)
|
|
|
|
end_test
|
2019-07-17 20:33:59 +00:00
|
|
|
|
2016-12-28 00:14:43 +00:00
|
|
|
begin_test "list a single lock (--json)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2017-01-06 16:15:16 +00:00
|
|
|
reponame="locks_list_single_json"
|
|
|
|
setup_remote_repo_with_file "$reponame" "f_json.dat"
|
2016-12-28 00:14:43 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "f_json.dat" | tee lock.log
|
2016-12-28 00:14:43 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
id=$(assert_lock lock.log f_json.dat)
|
2017-02-01 00:03:21 +00:00
|
|
|
assert_server_lock "$reponame" "$id"
|
2016-12-28 00:14:43 +00:00
|
|
|
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --json --path "f_json.dat" | tee locks.log
|
2016-12-28 00:14:43 +00:00
|
|
|
grep "\"path\":\"f_json.dat\"" locks.log
|
2017-02-03 17:48:31 +00:00
|
|
|
grep "\"owner\":{\"name\":\"Git LFS Tests\"}" locks.log
|
2016-12-28 00:14:43 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-06-03 23:24:38 +00:00
|
|
|
begin_test "list locks with a limit"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="locks_list_limit"
|
2017-02-01 00:03:21 +00:00
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "clone_$reponame"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "foo" > "g_1.dat"
|
|
|
|
echo "bar" > "g_2.dat"
|
|
|
|
|
|
|
|
git add "g_1.dat" "g_2.dat" ".gitattributes"
|
|
|
|
git commit -m "add files" | tee commit.log
|
|
|
|
grep "3 files changed" commit.log
|
|
|
|
grep "create mode 100644 g_1.dat" commit.log
|
|
|
|
grep "create mode 100644 g_2.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main 2>&1 | tee push.log
|
|
|
|
grep "main -> main" push.log
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "g_1.dat" | tee lock.log
|
|
|
|
assert_server_lock "$reponame" "$(assert_log "lock.log" g_1.dat)"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "g_2.dat" | tee lock.log
|
|
|
|
assert_server_lock "$reponame" "$(assert_lock "lock.log" g_2.dat)"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --limit 1 | tee locks.log
|
2017-02-23 20:02:42 +00:00
|
|
|
[ $(wc -l < locks.log) -eq 1 ]
|
2016-06-03 23:24:38 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "list locks with pagination"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="locks_list_paginate"
|
2017-02-01 00:03:21 +00:00
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "clone_$reponame"
|
2016-06-03 23:24:38 +00:00
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
for i in $(seq 1 5); do
|
|
|
|
echo "$i" > "h_$i.dat"
|
|
|
|
done
|
|
|
|
|
|
|
|
git add "h_1.dat" "h_2.dat" "h_3.dat" "h_4.dat" "h_5.dat" ".gitattributes"
|
|
|
|
|
|
|
|
git commit -m "add files" | tee commit.log
|
|
|
|
grep "6 files changed" commit.log
|
|
|
|
for i in $(seq 1 5); do
|
|
|
|
grep "create mode 100644 h_$i.dat" commit.log
|
|
|
|
done
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main 2>&1 | tee push.log
|
|
|
|
grep "main -> main" push.log
|
2016-06-03 23:24:38 +00:00
|
|
|
|
|
|
|
for i in $(seq 1 5); do
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "h_$i.dat" | tee lock.log
|
2019-05-26 17:19:07 +00:00
|
|
|
assert_server_lock "$reponame" "$(assert_lock "lock.log" "h_$i.dat")"
|
2016-06-03 23:24:38 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# The server will return, at most, three locks at a time
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --limit 4 | tee locks.log
|
2017-02-23 20:02:42 +00:00
|
|
|
[ $(wc -l < locks.log) -eq 4 ]
|
2016-06-03 23:24:38 +00:00
|
|
|
)
|
|
|
|
end_test
|
2016-12-12 14:56:40 +00:00
|
|
|
|
|
|
|
begin_test "cached locks"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="cached_locks"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "foo" > "cached1.dat"
|
|
|
|
echo "bar" > "cached2.dat"
|
|
|
|
|
|
|
|
git add "cached1.dat" "cached2.dat" ".gitattributes"
|
|
|
|
git commit -m "add files" | tee commit.log
|
|
|
|
grep "3 files changed" commit.log
|
|
|
|
grep "create mode 100644 cached1.dat" commit.log
|
|
|
|
grep "create mode 100644 cached2.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main 2>&1 | tee push.log
|
|
|
|
grep "main -> main" push.log
|
2016-12-12 14:56:40 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "cached1.dat" | tee lock.log
|
|
|
|
assert_server_lock "$(assert_lock "lock.log" cached1.dat)"
|
2016-12-12 14:56:40 +00:00
|
|
|
|
2017-02-23 19:47:14 +00:00
|
|
|
git lfs lock --json "cached2.dat" | tee lock.log
|
|
|
|
assert_server_lock "$(assert_lock "lock.log" cached2.dat)"
|
2016-12-12 14:56:40 +00:00
|
|
|
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --local | tee locks.log
|
2017-02-23 20:02:42 +00:00
|
|
|
[ $(wc -l < locks.log) -eq 2 ]
|
2016-12-12 14:56:40 +00:00
|
|
|
|
|
|
|
# delete the remote to prove we're using the local records
|
|
|
|
git remote remove origin
|
|
|
|
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --local --path "cached1.dat" | tee locks.log
|
2017-02-23 20:02:42 +00:00
|
|
|
[ $(wc -l < locks.log) -eq 1 ]
|
2016-12-12 14:56:40 +00:00
|
|
|
grep "cached1.dat" locks.log
|
|
|
|
|
2017-02-15 18:11:23 +00:00
|
|
|
git lfs locks --local --limit 1 | tee locks.log
|
2017-02-23 20:02:42 +00:00
|
|
|
[ $(wc -l < locks.log) -eq 1 ]
|
2016-12-12 14:56:40 +00:00
|
|
|
)
|
|
|
|
end_test
|