Skip to content

Commit d906662

Browse files
committed
Return a 204 response instead of 200
1 parent 83e3528 commit d906662

File tree

3 files changed

+6
-33
lines changed

3 files changed

+6
-33
lines changed

routers/api/v1/repo/branch.go

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ func UpdateBranch(ctx *context.APIContext) {
416416
// schema:
417417
// "$ref": "#/definitions/UpdateBranchRepoOption"
418418
// responses:
419-
// "200":
420-
// "$ref": "#/responses/Branch"
419+
// "204":
420+
// "$ref": "#/responses/empty"
421421
// "403":
422422
// "$ref": "#/responses/forbidden"
423423
// "404":
@@ -454,31 +454,7 @@ func UpdateBranch(ctx *context.APIContext) {
454454
return
455455
}
456456

457-
branch, err := ctx.Repo.GitRepo.GetBranch(opt.Name)
458-
if err != nil {
459-
ctx.Error(http.StatusInternalServerError, "GetBranch", err)
460-
return
461-
}
462-
463-
commit, err := branch.GetCommit()
464-
if err != nil {
465-
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
466-
return
467-
}
468-
469-
pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, repo.ID, branch.Name)
470-
if err != nil {
471-
ctx.Error(http.StatusInternalServerError, "GetFirstMatchProtectedBranchRule", err)
472-
return
473-
}
474-
475-
br, err := convert.ToBranch(ctx, repo, branch.Name, commit, pb, ctx.Doer, ctx.Repo.IsAdmin())
476-
if err != nil {
477-
ctx.Error(http.StatusInternalServerError, "ToBranch", err)
478-
return
479-
}
480-
481-
ctx.JSON(http.StatusOK, br)
457+
ctx.Status(http.StatusNoContent)
482458
}
483459

484460
// GetBranchProtection gets a branch protection

templates/swagger/v1_json.tmpl

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/api_branch_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@ func TestAPIUpdateBranch(t *testing.T) {
205205
assert.Contains(t, resp.Body.String(), "Branch doesn't exist.")
206206
})
207207
t.Run("RenameBranchNormalScenario", func(t *testing.T) {
208-
resp := testAPIUpdateBranch(t, "user2", "repo1", "branch2", "new-branch-name", http.StatusOK)
209-
var branch api.Branch
210-
DecodeJSON(t, resp, &branch)
211-
assert.EqualValues(t, "new-branch-name", branch.Name)
208+
testAPIUpdateBranch(t, "user2", "repo1", "branch2", "new-branch-name", http.StatusNoContent)
212209
})
213210
})
214211
}

0 commit comments

Comments
 (0)