locking: read SetLockableFilesReadOnly from OS/Git config

This commit is contained in:
Taylor Blau 2017-08-17 18:00:58 -06:00
parent 2ae1594579
commit 2360191931
3 changed files with 41 additions and 0 deletions

@ -86,6 +86,7 @@ func newLockClient(remote string) *locking.Client {
// Configure dirs
lockClient.LocalWorkingDir = config.LocalWorkingDir
lockClient.LocalGitDir = config.LocalGitDir
lockClient.SetLockableFilesReadOnly = cfg.SetLockableFilesReadOnly()
return lockClient
}

@ -19,6 +19,36 @@ begin_test "unlocking a lock by path"
)
end_test
begin_test "unlocking a file makes it readonly"
(
set -e
reponame="unlock_set_readonly"
setup_remote_repo_with_file "$reponame" "c.dat"
git lfs lock --json "c.dat"
assert_file_writeable c.dat
git lfs unlock "c.dat"
refute_file_writeable c.dat
)
end_test
begin_test "unlocking a file makes ignores readonly"
(
set -e
reponame="unlock_set_readonly_ignore"
setup_remote_repo_with_file "$reponame" "c.dat"
git lfs lock --json "c.dat"
assert_file_writeable c.dat
git -c lfs.setlockablereadonly=false lfs unlock "c.dat"
assert_file_writeable c.dat
)
end_test
begin_test "force unlocking lock with missing file"
(
set -e

@ -208,6 +208,16 @@ assert_attributes_count() {
fi
}
# Temporarily added to avoid a large diff in this pull request.
assert_file_writeable() {
assert_file_writable $@
}
# Temporarily added to avoid a large diff in this pull request.
refute_file_writeable() {
refute_file_writable $@
}
assert_file_writable() {
ls -l "$1" | grep -e "^-rw"
}