Merge pull request #5385 from salvorizza/json-unlock-id-fix

Unlock by ID with JSON Flag returns empty array
This commit is contained in:
brian m. carlson 2023-06-07 19:08:15 +00:00 committed by GitHub
commit 4f18bc4678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

@ -109,6 +109,11 @@ func unlockCommand(cmd *cobra.Command, args []string) {
success = false
} else if !locksCmdFlags.JSON {
Print(tr.Tr.Get("Unlocked Lock %s", unlockCmdFlags.Id))
} else {
locks = append(locks, unlockResponse{
Id: unlockCmdFlags.Id,
Unlocked: true,
})
}
} else {
Exit(tr.Tr.Get("Exactly one of --id or a set of paths must be provided"))

@ -308,6 +308,25 @@ begin_test "unlocking a lock by id"
)
end_test
begin_test "unlocking a lock by id (--json)"
(
set -e
reponame="unlock_by_id_json"
setup_repo "$reponame" "c_json.dat"
git lfs lock --json "c_json.dat" | tee lock.log
id=$(assert_lock lock.log c_json.dat)
assert_server_lock "$reponame" "$id"
git lfs unlock --json --id="$id" 2>&1 | tee unlock.log
grep "\"unlocked\":true" unlock.log
refute_server_lock "$reponame" "$id"
)
end_test
begin_test "unlocking a lock without sufficient info"
(
set -e