Skip to content

Commit e36b9c0

Browse files
committed
fix: refactor branch and tag existence checks
- Update branch existence check to also include tag existence check - Adjust error message for branch/tag existence check Signed-off-by: appleboy <[email protected]>
1 parent 48d4580 commit e36b9c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

routers/api/v1/repo/pull.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,8 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
10851085
log.Info("Base branch: %s", baseBranch)
10861086
log.Info("Repo path: %s", ctx.Repo.GitRepo.Path)
10871087
// Check if base branch is valid.
1088-
if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) {
1089-
ctx.NotFound("IsBranchExist")
1088+
if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) && !ctx.Repo.GitRepo.IsTagExist(baseBranch) {
1089+
ctx.NotFound("IsBranchExist && IsTagExist")
10901090
return nil, nil, nil, nil, "", ""
10911091
}
10921092

@@ -1149,7 +1149,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
11491149
}
11501150

11511151
// Check if head branch is valid.
1152-
if !headGitRepo.IsBranchExist(headBranch) {
1152+
if !headGitRepo.IsBranchExist(headBranch) && !headGitRepo.IsTagExist(headBranch) {
11531153
headGitRepo.Close()
11541154
ctx.NotFound()
11551155
return nil, nil, nil, nil, "", ""

0 commit comments

Comments
 (0)