Skip to content

Commit 0056fdb

Browse files
authored
Move git references checking to gitrepo packages to reduce expose of repository path (#33891)
1 parent f11ac6b commit 0056fdb

24 files changed

+79
-46
lines changed

modules/git/repo_tag.go

-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package git
66

77
import (
8-
"context"
98
"fmt"
109
"io"
1110
"strings"
@@ -17,11 +16,6 @@ import (
1716
// TagPrefix tags prefix path on the repository
1817
const TagPrefix = "refs/tags/"
1918

20-
// IsTagExist returns true if given tag exists in the repository.
21-
func IsTagExist(ctx context.Context, repoPath, name string) bool {
22-
return IsReferenceExist(ctx, repoPath, TagPrefix+name)
23-
}
24-
2519
// CreateTag create one tag in the repository
2620
func (repo *Repository) CreateTag(name, revision string) error {
2721
_, _, err := NewCommand("tag").AddDashesAndList(name, revision).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})

modules/gitrepo/branch.go

+18
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,21 @@ func GetDefaultBranch(ctx context.Context, repo Repository) (string, error) {
4747
func GetWikiDefaultBranch(ctx context.Context, repo Repository) (string, error) {
4848
return git.GetDefaultBranch(ctx, wikiPath(repo))
4949
}
50+
51+
// IsReferenceExist returns true if given reference exists in the repository.
52+
func IsReferenceExist(ctx context.Context, repo Repository, name string) bool {
53+
return git.IsReferenceExist(ctx, repoPath(repo), name)
54+
}
55+
56+
func IsWikiReferenceExist(ctx context.Context, repo Repository, name string) bool {
57+
return git.IsReferenceExist(ctx, wikiPath(repo), name)
58+
}
59+
60+
// IsBranchExist returns true if given branch exists in the repository.
61+
func IsBranchExist(ctx context.Context, repo Repository, name string) bool {
62+
return IsReferenceExist(ctx, repo, git.BranchPrefix+name)
63+
}
64+
65+
func IsWikiBranchExist(ctx context.Context, repo Repository, name string) bool {
66+
return IsWikiReferenceExist(ctx, repo, git.BranchPrefix+name)
67+
}

modules/gitrepo/tag.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package gitrepo
5+
6+
import (
7+
"context"
8+
9+
"code.gitea.io/gitea/modules/git"
10+
)
11+
12+
// IsTagExist returns true if given tag exists in the repository.
13+
func IsTagExist(ctx context.Context, repo Repository, name string) bool {
14+
return IsReferenceExist(ctx, repo, git.TagPrefix+name)
15+
}

routers/api/v1/repo/branch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func CreateBranch(ctx *context.APIContext) {
227227
return
228228
}
229229
} else if len(opt.OldBranchName) > 0 { //nolint
230-
if ctx.Repo.GitRepo.IsBranchExist(opt.OldBranchName) { //nolint
230+
if gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, opt.OldBranchName) { //nolint
231231
oldCommit, err = ctx.Repo.GitRepo.GetBranchCommit(opt.OldBranchName) //nolint
232232
if err != nil {
233233
ctx.APIErrorInternal(err)
@@ -1019,7 +1019,7 @@ func EditBranchProtection(ctx *context.APIContext) {
10191019
isPlainRule := !git_model.IsRuleNameSpecial(bpName)
10201020
var isBranchExist bool
10211021
if isPlainRule {
1022-
isBranchExist = git.IsBranchExist(ctx.Req.Context(), ctx.Repo.Repository.RepoPath(), bpName)
1022+
isBranchExist = gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, bpName)
10231023
}
10241024

10251025
if isBranchExist {

routers/api/v1/repo/pull.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ func EditPullRequest(ctx *context.APIContext) {
742742

743743
// change pull target branch
744744
if !pr.HasMerged && len(form.Base) != 0 && form.Base != pr.BaseBranch {
745-
if !ctx.Repo.GitRepo.IsBranchExist(form.Base) {
745+
if !gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, form.Base) {
746746
ctx.APIError(http.StatusNotFound, fmt.Errorf("new base '%s' not exist", form.Base))
747747
return
748748
}

routers/api/v1/repo/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
734734

735735
// Default branch only updated if changed and exist or the repository is empty
736736
updateRepoLicense := false
737-
if opts.DefaultBranch != nil && repo.DefaultBranch != *opts.DefaultBranch && (repo.IsEmpty || ctx.Repo.GitRepo.IsBranchExist(*opts.DefaultBranch)) {
737+
if opts.DefaultBranch != nil && repo.DefaultBranch != *opts.DefaultBranch && (repo.IsEmpty || gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, *opts.DefaultBranch)) {
738738
if !repo.IsEmpty {
739739
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, *opts.DefaultBranch); err != nil {
740740
ctx.APIErrorInternal(err)

routers/private/hook_pre_receive.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/models/unit"
1717
user_model "code.gitea.io/gitea/models/user"
1818
"code.gitea.io/gitea/modules/git"
19+
"code.gitea.io/gitea/modules/gitrepo"
1920
"code.gitea.io/gitea/modules/log"
2021
"code.gitea.io/gitea/modules/private"
2122
"code.gitea.io/gitea/modules/web"
@@ -447,13 +448,13 @@ func preReceiveFor(ctx *preReceiveContext, refFullName git.RefName) {
447448
baseBranchName := refFullName.ForBranchName()
448449

449450
baseBranchExist := false
450-
if ctx.Repo.GitRepo.IsBranchExist(baseBranchName) {
451+
if gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, baseBranchName) {
451452
baseBranchExist = true
452453
}
453454

454455
if !baseBranchExist {
455456
for p, v := range baseBranchName {
456-
if v == '/' && ctx.Repo.GitRepo.IsBranchExist(baseBranchName[:p]) && p != len(baseBranchName)-1 {
457+
if v == '/' && gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, baseBranchName[:p]) && p != len(baseBranchName)-1 {
457458
baseBranchExist = true
458459
break
459460
}

routers/web/repo/compare.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
301301

302302
// Check if base branch is valid.
303303
baseIsCommit := ctx.Repo.GitRepo.IsCommitExist(ci.BaseBranch)
304-
baseIsBranch := ctx.Repo.GitRepo.IsBranchExist(ci.BaseBranch)
305-
baseIsTag := ctx.Repo.GitRepo.IsTagExist(ci.BaseBranch)
304+
baseIsBranch := gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, ci.BaseBranch)
305+
baseIsTag := gitrepo.IsTagExist(ctx, ctx.Repo.Repository, ci.BaseBranch)
306306

307307
if !baseIsCommit && !baseIsBranch && !baseIsTag {
308308
// Check if baseBranch is short sha commit hash
@@ -504,8 +504,8 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
504504

505505
// Check if head branch is valid.
506506
headIsCommit := ci.HeadGitRepo.IsCommitExist(ci.HeadBranch)
507-
headIsBranch := ci.HeadGitRepo.IsBranchExist(ci.HeadBranch)
508-
headIsTag := ci.HeadGitRepo.IsTagExist(ci.HeadBranch)
507+
headIsBranch := gitrepo.IsBranchExist(ctx, ci.HeadRepo, ci.HeadBranch)
508+
headIsTag := gitrepo.IsTagExist(ctx, ci.HeadRepo, ci.HeadBranch)
509509
if !headIsCommit && !headIsBranch && !headIsTag {
510510
// Check if headBranch is short sha commit hash
511511
if headCommit, _ := ci.HeadGitRepo.GetCommit(ci.HeadBranch); headCommit != nil {

routers/web/repo/issue_comment.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/models/renderhelper"
1414
user_model "code.gitea.io/gitea/models/user"
1515
"code.gitea.io/gitea/modules/git"
16+
"code.gitea.io/gitea/modules/gitrepo"
1617
"code.gitea.io/gitea/modules/log"
1718
"code.gitea.io/gitea/modules/markup/markdown"
1819
repo_module "code.gitea.io/gitea/modules/repository"
@@ -117,7 +118,7 @@ func NewComment(ctx *context.Context) {
117118
ctx.ServerError("Unable to load head repo", err)
118119
return
119120
}
120-
if ok := git.IsBranchExist(ctx, pull.HeadRepo.RepoPath(), pull.BaseBranch); !ok {
121+
if ok := gitrepo.IsBranchExist(ctx, pull.HeadRepo, pull.BaseBranch); !ok {
121122
// todo localize
122123
ctx.JSONError("The origin branch is delete, cannot reopen.")
123124
return

routers/web/repo/issue_view.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
user_model "code.gitea.io/gitea/models/user"
2525
"code.gitea.io/gitea/modules/emoji"
2626
"code.gitea.io/gitea/modules/git"
27+
"code.gitea.io/gitea/modules/gitrepo"
2728
"code.gitea.io/gitea/modules/log"
2829
"code.gitea.io/gitea/modules/markup"
2930
"code.gitea.io/gitea/modules/markup/markdown"
@@ -526,7 +527,7 @@ func preparePullViewDeleteBranch(ctx *context.Context, issue *issues_model.Issue
526527
pull := issue.PullRequest
527528
isPullBranchDeletable := canDelete &&
528529
pull.HeadRepo != nil &&
529-
git.IsBranchExist(ctx, pull.HeadRepo.RepoPath(), pull.HeadBranch) &&
530+
gitrepo.IsBranchExist(ctx, pull.HeadRepo, pull.HeadBranch) &&
530531
(!pull.HasMerged || ctx.Data["HeadBranchCommitID"] == ctx.Data["PullHeadCommitID"])
531532

532533
if isPullBranchDeletable && pull.HasMerged {

routers/web/repo/pull.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func prepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
347347
defer baseGitRepo.Close()
348348
}
349349

350-
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
350+
if !gitrepo.IsBranchExist(ctx, pull.BaseRepo, pull.BaseBranch) {
351351
ctx.Data["BaseBranchNotExist"] = true
352352
ctx.Data["IsPullRequestBroken"] = true
353353
ctx.Data["BaseTarget"] = pull.BaseBranch
@@ -404,9 +404,9 @@ func prepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
404404
defer closer.Close()
405405

406406
if pull.Flow == issues_model.PullRequestFlowGithub {
407-
headBranchExist = headGitRepo.IsBranchExist(pull.HeadBranch)
407+
headBranchExist = gitrepo.IsBranchExist(ctx, pull.HeadRepo, pull.HeadBranch)
408408
} else {
409-
headBranchExist = git.IsReferenceExist(ctx, baseGitRepo.Path, pull.GetGitRefName())
409+
headBranchExist = gitrepo.IsReferenceExist(ctx, pull.BaseRepo, pull.GetGitRefName())
410410
}
411411

412412
if headBranchExist {

routers/web/repo/release.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"code.gitea.io/gitea/models/unit"
1818
user_model "code.gitea.io/gitea/models/user"
1919
"code.gitea.io/gitea/modules/git"
20+
"code.gitea.io/gitea/modules/gitrepo"
2021
"code.gitea.io/gitea/modules/markup/markdown"
2122
"code.gitea.io/gitea/modules/optional"
2223
"code.gitea.io/gitea/modules/setting"
@@ -420,7 +421,7 @@ func NewReleasePost(ctx *context.Context) {
420421
return
421422
}
422423

423-
if !ctx.Repo.GitRepo.IsBranchExist(form.Target) {
424+
if !gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, form.Target) {
424425
ctx.RenderWithErr(ctx.Tr("form.target_branch_not_exist"), tplReleaseNew, &form)
425426
return
426427
}

routers/web/repo/setting/default_branch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func SetDefaultBranchPost(ctx *context.Context) {
3434
}
3535

3636
branch := ctx.FormString("branch")
37-
if err := repo_service.SetRepoDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, branch); err != nil {
37+
if err := repo_service.SetRepoDefaultBranch(ctx, ctx.Repo.Repository, branch); err != nil {
3838
switch {
3939
case git_model.IsErrBranchNotExist(err):
4040
ctx.Status(http.StatusNotFound)

services/agit/agit.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
repo_model "code.gitea.io/gitea/models/repo"
1414
user_model "code.gitea.io/gitea/models/user"
1515
"code.gitea.io/gitea/modules/git"
16+
"code.gitea.io/gitea/modules/gitrepo"
1617
"code.gitea.io/gitea/modules/log"
1718
"code.gitea.io/gitea/modules/private"
1819
"code.gitea.io/gitea/modules/setting"
@@ -56,10 +57,10 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
5657

5758
baseBranchName := opts.RefFullNames[i].ForBranchName()
5859
currentTopicBranch := ""
59-
if !gitRepo.IsBranchExist(baseBranchName) {
60+
if !gitrepo.IsBranchExist(ctx, repo, baseBranchName) {
6061
// try match refs/for/<target-branch>/<topic-branch>
6162
for p, v := range baseBranchName {
62-
if v == '/' && gitRepo.IsBranchExist(baseBranchName[:p]) && p != len(baseBranchName)-1 {
63+
if v == '/' && gitrepo.IsBranchExist(ctx, repo, baseBranchName[:p]) && p != len(baseBranchName)-1 {
6364
currentTopicBranch = baseBranchName[p+1:]
6465
baseBranchName = baseBranchName[:p]
6566
break

services/automerge/automerge.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ func handlePullRequestAutoMerge(pullID int64, sha string) {
248248

249249
switch pr.Flow {
250250
case issues_model.PullRequestFlowGithub:
251-
headBranchExist := headGitRepo.IsBranchExist(pr.HeadBranch)
252-
if pr.HeadRepo == nil || !headBranchExist {
251+
headBranchExist := pr.HeadRepo != nil && gitrepo.IsBranchExist(ctx, pr.HeadRepo, pr.HeadBranch)
252+
if !headBranchExist {
253253
log.Warn("Head branch of auto merge %-v does not exist [HeadRepoID: %d, Branch: %s]", pr, pr.HeadRepoID, pr.HeadBranch)
254254
return
255255
}
256256
case issues_model.PullRequestFlowAGit:
257-
headBranchExist := git.IsReferenceExist(ctx, baseGitRepo.Path, pr.GetGitRefName())
257+
headBranchExist := gitrepo.IsReferenceExist(ctx, pr.BaseRepo, pr.GetGitRefName())
258258
if !headBranchExist {
259259
log.Warn("Head branch of auto merge %-v does not exist [HeadRepoID: %d, Branch(Agit): %s]", pr, pr.HeadRepoID, pr.HeadBranch)
260260
return

services/context/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,14 @@ func RepoRefForAPI(next http.Handler) http.Handler {
304304
refName, _, _ := getRefNameLegacy(ctx.Base, ctx.Repo, ctx.PathParam("*"), ctx.FormTrim("ref"))
305305
var err error
306306

307-
if ctx.Repo.GitRepo.IsBranchExist(refName) {
307+
if gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, refName) {
308308
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName)
309309
if err != nil {
310310
ctx.APIErrorInternal(err)
311311
return
312312
}
313313
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
314-
} else if ctx.Repo.GitRepo.IsTagExist(refName) {
314+
} else if gitrepo.IsTagExist(ctx, ctx.Repo.Repository, refName) {
315315
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetTagCommit(refName)
316316
if err != nil {
317317
ctx.APIErrorInternal(err)

services/context/repo.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
814814
reqPath := ctx.PathParam("*")
815815
if reqPath == "" {
816816
refShortName = ctx.Repo.Repository.DefaultBranch
817-
if !ctx.Repo.GitRepo.IsBranchExist(refShortName) {
817+
if !gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, refShortName) {
818818
brs, _, err := ctx.Repo.GitRepo.GetBranches(0, 1)
819819
if err == nil && len(brs) != 0 {
820820
refShortName = brs[0].Name
@@ -854,7 +854,7 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
854854
return
855855
}
856856

857-
if refType == git.RefTypeBranch && ctx.Repo.GitRepo.IsBranchExist(refShortName) {
857+
if refType == git.RefTypeBranch && gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, refShortName) {
858858
ctx.Repo.BranchName = refShortName
859859
ctx.Repo.RefFullName = git.RefNameFromBranch(refShortName)
860860

@@ -864,7 +864,7 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
864864
return
865865
}
866866
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
867-
} else if refType == git.RefTypeTag && ctx.Repo.GitRepo.IsTagExist(refShortName) {
867+
} else if refType == git.RefTypeTag && gitrepo.IsTagExist(ctx, ctx.Repo.Repository, refShortName) {
868868
ctx.Repo.RefFullName = git.RefNameFromTag(refShortName)
869869

870870
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetTagCommit(refShortName)

services/pull/commit_status.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
git_model "code.gitea.io/gitea/models/git"
1212
issues_model "code.gitea.io/gitea/models/issues"
13-
"code.gitea.io/gitea/modules/git"
1413
"code.gitea.io/gitea/modules/gitrepo"
1514
"code.gitea.io/gitea/modules/log"
1615
"code.gitea.io/gitea/modules/structs"
@@ -131,10 +130,10 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullR
131130
}
132131
defer closer.Close()
133132

134-
if pr.Flow == issues_model.PullRequestFlowGithub && !headGitRepo.IsBranchExist(pr.HeadBranch) {
133+
if pr.Flow == issues_model.PullRequestFlowGithub && !gitrepo.IsBranchExist(ctx, pr.HeadRepo, pr.HeadBranch) {
135134
return "", errors.New("Head branch does not exist, can not merge")
136135
}
137-
if pr.Flow == issues_model.PullRequestFlowAGit && !git.IsReferenceExist(ctx, headGitRepo.Path, pr.GetGitRefName()) {
136+
if pr.Flow == issues_model.PullRequestFlowAGit && !gitrepo.IsReferenceExist(ctx, pr.HeadRepo, pr.GetGitRefName()) {
138137
return "", errors.New("Head branch does not exist, can not merge")
139138
}
140139

services/pull/protected_branch.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
git_model "code.gitea.io/gitea/models/git"
1010
repo_model "code.gitea.io/gitea/models/repo"
11-
"code.gitea.io/gitea/modules/git"
11+
"code.gitea.io/gitea/modules/gitrepo"
1212
)
1313

1414
func CreateOrUpdateProtectedBranch(ctx context.Context, repo *repo_model.Repository,
@@ -22,7 +22,8 @@ func CreateOrUpdateProtectedBranch(ctx context.Context, repo *repo_model.Reposit
2222
isPlainRule := !git_model.IsRuleNameSpecial(protectBranch.RuleName)
2323
var isBranchExist bool
2424
if isPlainRule {
25-
isBranchExist = git.IsBranchExist(ctx, repo.RepoPath(), protectBranch.RuleName)
25+
// TODO: read the database directly to check if the branch exists
26+
isBranchExist = gitrepo.IsBranchExist(ctx, repo, protectBranch.RuleName)
2627
}
2728

2829
if isBranchExist {

services/pull/pull.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func AddTestPullRequestTask(opts TestPullRequestOptions) {
491491
for _, pr := range prs {
492492
divergence, err := GetDiverging(ctx, pr)
493493
if err != nil {
494-
if git_model.IsErrBranchNotExist(err) && !git.IsBranchExist(ctx, pr.HeadRepo.RepoPath(), pr.HeadBranch) {
494+
if git_model.IsErrBranchNotExist(err) && !gitrepo.IsBranchExist(ctx, pr.HeadRepo, pr.HeadBranch) {
495495
log.Warn("Cannot test PR %s/%d: head_branch %s no longer exists", pr.BaseRepo.Name, pr.IssueID, pr.HeadBranch)
496496
} else {
497497
log.Error("GetDiverging: %v", err)

services/pull/temp_repo.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
issues_model "code.gitea.io/gitea/models/issues"
1616
repo_model "code.gitea.io/gitea/models/repo"
1717
"code.gitea.io/gitea/modules/git"
18+
"code.gitea.io/gitea/modules/gitrepo"
1819
"code.gitea.io/gitea/modules/log"
1920
repo_module "code.gitea.io/gitea/modules/repository"
2021
)
@@ -181,7 +182,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
181182
if err := git.NewCommand("fetch").AddArguments(fetchArgs...).AddDynamicArguments(remoteRepoName, headBranch+":"+trackingBranch).
182183
Run(ctx, prCtx.RunOpts()); err != nil {
183184
cancel()
184-
if !git.IsBranchExist(ctx, pr.HeadRepo.RepoPath(), pr.HeadBranch) {
185+
if !gitrepo.IsBranchExist(ctx, pr.HeadRepo, pr.HeadBranch) {
185186
return nil, nil, git_model.ErrBranchNotExist{
186187
BranchName: pr.HeadBranch,
187188
}

services/release/release.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func createTag(ctx context.Context, gitRepo *git.Repository, rel *repo_model.Rel
7777
var created bool
7878
// Only actual create when publish.
7979
if !rel.IsDraft {
80-
if !gitRepo.IsTagExist(rel.TagName) {
80+
if !gitrepo.IsTagExist(ctx, rel.Repo, rel.TagName) {
8181
if err := rel.LoadAttributes(ctx); err != nil {
8282
log.Error("LoadAttributes: %v", err)
8383
return false, err

0 commit comments

Comments
 (0)