1
1
mirror of https://github.com/go-gitea/gitea synced 2025-11-09 07:48:13 +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

@@ -8,7 +8,6 @@ import (
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/gitrepo"
)
func CreateOrUpdateProtectedBranch(ctx context.Context, repo *repo_model.Repository,
@@ -22,8 +21,7 @@ func CreateOrUpdateProtectedBranch(ctx context.Context, repo *repo_model.Reposit
isPlainRule := !git_model.IsRuleNameSpecial(protectBranch.RuleName)
var isBranchExist bool
if isPlainRule {
// TODO: read the database directly to check if the branch exists
isBranchExist = gitrepo.IsBranchExist(ctx, repo, protectBranch.RuleName)
isBranchExist, _ = git_model.IsBranchExist(ctx, repo.ID, protectBranch.RuleName)
}
if isBranchExist {