mirror of
1
Fork 0

check IsCommitExist

(cherry picked from commit e434ecdaca)
This commit is contained in:
angelnu 2024-11-16 18:12:40 +01:00 committed by forgejo-backport-action
parent 5058c76f3e
commit a27e4bb586
1 changed files with 2 additions and 2 deletions

View File

@ -1087,7 +1087,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
ctx.Repo.PullRequest.SameRepo = isSameRepo ctx.Repo.PullRequest.SameRepo = isSameRepo
log.Trace("Repo path: %q, base branch: %q, head branch: %q", ctx.Repo.GitRepo.Path, baseBranch, headBranch) log.Trace("Repo path: %q, base branch: %q, head branch: %q", ctx.Repo.GitRepo.Path, baseBranch, headBranch)
// Check if base branch is valid. // Check if base branch is valid.
if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) && !ctx.Repo.GitRepo.IsTagExist(baseBranch) { if !ctx.Repo.GitRepo.IsCommitExist(baseBranch) && !ctx.Repo.GitRepo.IsBranchExist(baseBranch) && !ctx.Repo.GitRepo.IsTagExist(baseBranch) {
ctx.NotFound("BaseNotExist") ctx.NotFound("BaseNotExist")
return nil, nil, nil, "", "" return nil, nil, nil, "", ""
} }
@ -1162,7 +1162,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
} }
// Check if head branch is valid. // Check if head branch is valid.
if !headGitRepo.IsBranchExist(headBranch) && !headGitRepo.IsTagExist(headBranch) { if !ctx.Repo.GitRepo.IsCommitExist(baseBranch) && !headGitRepo.IsBranchExist(headBranch) && !headGitRepo.IsTagExist(headBranch) {
headGitRepo.Close() headGitRepo.Close()
ctx.NotFound() ctx.NotFound()
return nil, nil, nil, "", "" return nil, nil, nil, "", ""