Skip to content

Commit d173d4e

Browse files
committed
temp
1 parent 114d73f commit d173d4e

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

routers/api/v1/repo/status.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
package repo
55

66
import (
7-
"errors"
87
"fmt"
98
"net/http"
109

1110
"code.gitea.io/gitea/models/db"
1211
git_model "code.gitea.io/gitea/models/git"
1312
api "code.gitea.io/gitea/modules/structs"
14-
"code.gitea.io/gitea/modules/util"
1513
"code.gitea.io/gitea/modules/web"
1614
"code.gitea.io/gitea/routers/api/v1/utils"
1715
"code.gitea.io/gitea/services/context"
@@ -179,13 +177,8 @@ func GetCommitStatusesByRef(ctx *context.APIContext) {
179177
// "404":
180178
// "$ref": "#/responses/notFound"
181179

182-
refCommit, err := utils.ResolveRefCommit(ctx, ctx.PathParam("ref"))
183-
if err != nil {
184-
if errors.Is(err, util.ErrNotExist) {
185-
ctx.APIErrorNotFound(err)
186-
} else {
187-
ctx.APIErrorInternal(err)
188-
}
180+
refCommit := resolveRefCommit(ctx, ctx.PathParam("ref"))
181+
if ctx.Written() {
189182
return
190183
}
191184
getCommitStatuses(ctx, refCommit.CommitID)
@@ -258,13 +251,8 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
258251
// "404":
259252
// "$ref": "#/responses/notFound"
260253

261-
refCommit, err := utils.ResolveRefCommit(ctx, ctx.PathParam("ref"))
262-
if err != nil {
263-
if errors.Is(err, util.ErrNotExist) {
264-
ctx.APIErrorNotFound(err)
265-
} else {
266-
ctx.APIErrorInternal(err)
267-
}
254+
refCommit := resolveRefCommit(ctx, ctx.PathParam("ref"))
255+
if ctx.Written() {
268256
return
269257
}
270258

routers/api/v1/utils/git.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type RefCommit struct {
2020

2121
// ResolveRefCommit resolve ref to a commit if exist
2222
func ResolveRefCommit(ctx *context.APIContext, inputRef string) (_ *RefCommit, err error) {
23-
var refCommit RefCommit
23+
refCommit := RefCommit{InputRef: inputRef}
2424
if gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, inputRef) {
2525
refCommit.Ref = git.RefNameFromBranch(inputRef)
2626
} else if gitrepo.IsTagExist(ctx, ctx.Repo.Repository, inputRef) {
@@ -34,7 +34,6 @@ func ResolveRefCommit(ctx *context.APIContext, inputRef string) (_ *RefCommit, e
3434
if refCommit.Commit, err = ctx.Repo.GitRepo.GetCommit(refCommit.Ref.String()); err != nil {
3535
return nil, err
3636
}
37-
refCommit.InputRef = inputRef
3837
refCommit.CommitID = refCommit.Commit.ID.String()
3938
return &refCommit, nil
4039
}

0 commit comments

Comments
 (0)