36b0664fe0
To prepare for the upcoming release of Git LFS v1.3, the `git-lfs lock` and `git-lfs locks` commands are now hidden behind a enviornment variable `GITLFSLOCKSENABLED`. Since most (all?) implementations of LFS do not yet support this new locking API, it makes sense to allow users to experiment with the command while at the same time, not making it a "full" part of the release. If users wish to run any `git-lfs lock{,s}` command, they may do so according to the following: ``` $ GITLFSLOCKSEANBLED=1 git lfs lock <flags> [args] $ GITLFSLOCKSEANBLED=1 git lfs locks <flags> [args] ``` This commit, when applied, adds two new things: 1. The `isCommandEnabled(cmd string) bool` func in the commands package. This new func checks the OS's enviornment variables and determines whether or not a command is "enabled". 2. Updates the `lock` and `locks` tests to use the GITLFSLOCKSENABLED=1 flag such that they are able to run. Since the `isCommandEnabled` func defaults to "false", it should only guard commands which are deemed "experimental", as noted in the godoc.
91 lines
2.3 KiB
Bash
Executable File
91 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
. "test/testlib.sh"
|
|
|
|
begin_test "list a single lock"
|
|
(
|
|
set -e
|
|
|
|
setup_remote_repo_with_file "locks_list_single" "f.dat"
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs lock "f.dat" | tee lock.log
|
|
|
|
id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
|
|
assert_server_lock $id
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs locks --path "f.dat" | tee locks.log
|
|
grep "1 lock(s) matched query" locks.log
|
|
grep "f.dat" locks.log
|
|
)
|
|
end_test
|
|
|
|
begin_test "list locks with a limit"
|
|
(
|
|
set -e
|
|
|
|
reponame="locks_list_limit"
|
|
setup_remote_repo "remote_$reponame"
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
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
|
|
|
|
|
|
git push origin master 2>&1 | tee push.log
|
|
grep "master -> master" push.log
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs lock "g_1.dat" | tee lock.log
|
|
assert_server_lock "$(grep -oh "\((.*)\)" lock.log | tr -d "()")"
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs lock "g_2.dat" | tee lock.log
|
|
assert_server_lock "$(grep -oh "\((.*)\)" lock.log | tr -d "()")"
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs locks --limit 1 | tee locks.log
|
|
grep "1 lock(s) matched query" locks.log
|
|
)
|
|
end_test
|
|
|
|
begin_test "list locks with pagination"
|
|
(
|
|
set -e
|
|
|
|
reponame="locks_list_paginate"
|
|
setup_remote_repo "remote_$reponame"
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
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
|
|
|
|
git push origin master 2>&1 | tee push.log
|
|
grep "master -> master" push.log
|
|
|
|
for i in $(seq 1 5); do
|
|
GITLFSLOCKSENABLED=1 git lfs lock "h_$i.dat" | tee lock.log
|
|
assert_server_lock "$(grep -oh "\((.*)\)" lock.log | tr -d "()")"
|
|
done
|
|
|
|
# The server will return, at most, three locks at a time
|
|
GITLFSLOCKSENABLED=1 git lfs locks --limit 4 | tee locks.log
|
|
grep "4 lock(s) matched query" locks.log
|
|
)
|
|
end_test
|