Skip to content

Commit 0746d8d

Browse files
committed
Return 204 instead of error when commit not exist
Fix #31976
1 parent 74b1c58 commit 0746d8d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

routers/api/v1/repo/commits.go

+6
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ func GetAllCommits(ctx *context.APIContext) {
144144
// responses:
145145
// "200":
146146
// "$ref": "#/responses/CommitList"
147+
// "204":
148+
// "description": "StatusNoContents indicates no commits found matching particular SHA"
147149
// "404":
148150
// "$ref": "#/responses/notFound"
149151
// "409":
@@ -195,6 +197,10 @@ func GetAllCommits(ctx *context.APIContext) {
195197
// get commit specified by sha
196198
baseCommit, err = ctx.Repo.GitRepo.GetCommit(sha)
197199
if err != nil {
200+
if git.IsErrNotExist(err) {
201+
ctx.Status(http.StatusNoContent)
202+
return
203+
}
198204
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
199205
return
200206
}

templates/swagger/v1_json.tmpl

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)