1
1
mirror of https://github.com/go-gitea/gitea synced 2025-10-31 03:18:24 +00:00

Use git model to detect whether branch exist instead of gitrepo method (#35459)

This commit is contained in:
Lunny Xiao
2025-10-25 10:08:25 -07:00
committed by GitHub
parent 304d836a61
commit 5454fdacd4
18 changed files with 165 additions and 54 deletions

View File

@@ -6,6 +6,7 @@ package utils
import (
"errors"
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
@@ -27,7 +28,7 @@ func ResolveRefCommit(ctx reqctx.RequestContext, repo *repo_model.Repository, in
return nil, err
}
refCommit := RefCommit{InputRef: inputRef}
if gitrepo.IsBranchExist(ctx, repo, inputRef) {
if exist, _ := git_model.IsBranchExist(ctx, repo.ID, inputRef); exist {
refCommit.RefName = git.RefNameFromBranch(inputRef)
} else if gitrepo.IsTagExist(ctx, repo, inputRef) {
refCommit.RefName = git.RefNameFromTag(inputRef)