Merge pull request #2514 from git-lfs/lock-respect-set-read-only

locking: read SetLockableFilesReadOnly from OS/Git config
This commit is contained in:
Taylor Blau 2017-09-07 16:37:43 -04:00 committed by GitHub
commit f3a4a3c0ab
3 changed files with 36 additions and 2 deletions

@ -40,9 +40,12 @@ func unlockCommand(cmd *cobra.Command, args []string) {
if hasPath {
path, err := lockPath(args[0])
if err != nil && !unlockCmdFlags.Force {
if err != nil {
if !unlockCmdFlags.Force {
Exit("Unable to determine path: %v", err.Error())
}
path = args[0]
}
// This call can early-out
unlockAbortIfFileModified(path, !os.IsNotExist(err))

@ -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