From 66e0988a43bb81031182a83891c2d3efa4c4b2f3 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 28 Jun 2025 20:27:41 +0200 Subject: [PATCH] feat: make API pull and compare endpoint references to head more robust It is best to prefix the reference to resolve any ambiguity once it has been determined that it is a branch or a tag. It was done in forgejo/forgejo#5991 for the base reference but not for the head reference. Refs forgejo/forgejo#5991 --- routers/api/v1/repo/pull.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 20f718d6c2..e7ff533d6a 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -1202,6 +1202,11 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) } headBranchRef := headBranch + if headIsBranch { + headBranchRef = git.BranchPrefix + headBranch + } else if headIsTag { + headBranchRef = git.TagPrefix + headBranch + } compareInfo, err := headGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), baseBranchRef, headBranchRef, false, false) if err != nil {