From a27e4bb586a2476647bf477acc76aceaab7d4565 Mon Sep 17 00:00:00 2001 From: angelnu Date: Sat, 16 Nov 2024 18:12:40 +0100 Subject: [PATCH] check IsCommitExist (cherry picked from commit e434ecdacaa0ea8004317fae1b355ad9bd8f274e) --- routers/api/v1/repo/pull.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index f491fd2735..ac1f038131 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -1087,7 +1087,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) ctx.Repo.PullRequest.SameRepo = isSameRepo log.Trace("Repo path: %q, base branch: %q, head branch: %q", ctx.Repo.GitRepo.Path, baseBranch, headBranch) // 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") return nil, nil, nil, "", "" } @@ -1162,7 +1162,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) } // 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() ctx.NotFound() return nil, nil, nil, "", ""