Skip to content

Commit

Permalink
fix: refactor branch and tag existence checks
Browse files Browse the repository at this point in the history
- Update branch existence check to also include tag existence check
- Adjust error message for branch/tag existence check

Signed-off-by: appleboy <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Apr 20, 2024
1 parent 48d4580 commit e36b9c0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions routers/api/v1/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,8 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
log.Info("Base branch: %s", baseBranch)
log.Info("Repo path: %s", ctx.Repo.GitRepo.Path)
// Check if base branch is valid.
if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) {
ctx.NotFound("IsBranchExist")
if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) && !ctx.Repo.GitRepo.IsTagExist(baseBranch) {
ctx.NotFound("IsBranchExist && IsTagExist")
return nil, nil, nil, nil, "", ""
}

Expand Down Expand Up @@ -1149,7 +1149,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
}

// Check if head branch is valid.
if !headGitRepo.IsBranchExist(headBranch) {
if !headGitRepo.IsBranchExist(headBranch) && !headGitRepo.IsTagExist(headBranch) {
headGitRepo.Close()
ctx.NotFound()
return nil, nil, nil, nil, "", ""
Expand Down

0 comments on commit e36b9c0

Please sign in to comment.