mirror of https://github.com/go-gitea/gitea.git
Keep "non-existent branch" HTTP responses consistent
This commit is contained in:
parent
1ad8de7ac7
commit
e4f7307511
|
@ -462,7 +462,7 @@ func UpdateBranch(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
if msg == "from_not_exist" {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", "Branch doesn't exist.")
|
||||
ctx.Error(http.StatusNotFound, "", "Branch doesn't exist.")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -474,7 +474,7 @@ func UpdateBranch(ctx *context.APIContext) {
|
|||
if git.IsErrBranchNotExist(err) {
|
||||
// This could occur if the client passes a non-existent branch and we
|
||||
// skip executing the branch that contains the RenameBranch() call.
|
||||
ctx.NotFound(err)
|
||||
ctx.Error(http.StatusNotFound, "", "Branch doesn't exist.")
|
||||
return
|
||||
}
|
||||
ctx.Error(http.StatusInternalServerError, "GetBranch", err)
|
||||
|
|
|
@ -201,7 +201,7 @@ func TestAPIUpdateBranch(t *testing.T) {
|
|||
assert.Contains(t, resp.Body.String(), "Cannot rename a branch using the same name or rename to a branch that already exists.")
|
||||
})
|
||||
t.Run("UpdateBranchWithNonExistentBranch", func(t *testing.T) {
|
||||
resp := testAPIUpdateBranch(t, "user2", "repo1", "i-dont-exist", "new-branch-name", http.StatusUnprocessableEntity)
|
||||
resp := testAPIUpdateBranch(t, "user2", "repo1", "i-dont-exist", "new-branch-name", http.StatusNotFound)
|
||||
assert.Contains(t, resp.Body.String(), "Branch doesn't exist.")
|
||||
})
|
||||
t.Run("UpdateBranchWithEmptyStringAsNewName", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue