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.
62 lines
1.4 KiB
Bash
Executable File
62 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
. "test/testlib.sh"
|
|
|
|
begin_test "creating a lock"
|
|
(
|
|
set -e
|
|
|
|
setup_remote_repo_with_file "lock_create_simple" "a.dat"
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs lock "a.dat" | tee lock.log
|
|
grep "'a.dat' was locked" lock.log
|
|
|
|
id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
|
|
assert_server_lock $id
|
|
)
|
|
end_test
|
|
|
|
begin_test "locking a previously locked file"
|
|
(
|
|
set -e
|
|
|
|
setup_remote_repo_with_file "lock_create_previously_created" "b.dat"
|
|
|
|
GITLFSLOCKSENABLED=1 git lfs lock "b.dat" | tee lock.log
|
|
grep "'b.dat' was locked" lock.log
|
|
|
|
id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
|
|
assert_server_lock $id
|
|
|
|
grep "lock already created" <(GITLFSLOCKSENABLED=1 git lfs lock "b.dat" 2>&1)
|
|
)
|
|
end_test
|
|
|
|
begin_test "locking a directory"
|
|
(
|
|
set -e
|
|
|
|
reponame="locking_directories"
|
|
setup_remote_repo "remote_$reponame"
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
git lfs track "*.dat"
|
|
mkdir dir
|
|
echo "a" > dir/a.dat
|
|
|
|
git add dir/a.dat .gitattributes
|
|
|
|
git commit -m "add dir/a.dat" | tee commit.log
|
|
grep "master (root-commit)" commit.log
|
|
grep "2 files changed" commit.log
|
|
grep "create mode 100644 dir/a.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 ./dir/ 2>&1 | tee lock.log
|
|
grep "cannot lock directory" lock.log
|
|
)
|
|
end_test
|