aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/compare.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-06-12 00:49:47 +0100
committerGitHub <noreply@github.com>2020-06-11 19:49:47 -0400
commit0973c036019c955172ebce99d58eede2e9ac55ca (patch)
tree7c49364bba0ebfb4eb8c4bb5194f643629b929bc /routers/repo/compare.go
parent6c2a59b50c2af367281492b6c6adc9061e57b0a9 (diff)
downloadgitea-0973c036019c955172ebce99d58eede2e9ac55ca.tar.gz
gitea-0973c036019c955172ebce99d58eede2e9ac55ca.zip
Handle more pathological branch and tag names (#11843)
* Handle more pathological branch and tag names Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix failing test Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/repo/compare.go')
-rw-r--r--routers/repo/compare.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/routers/repo/compare.go b/routers/repo/compare.go
index 858e4e548e..25aff0eeba 100644
--- a/routers/repo/compare.go
+++ b/routers/repo/compare.go
@@ -381,7 +381,20 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
return nil, nil, nil, nil, "", ""
}
- compareInfo, err := headGitRepo.GetCompareInfo(baseRepo.RepoPath(), baseBranch, headBranch)
+ baseBranchRef := baseBranch
+ if baseIsBranch {
+ baseBranchRef = git.BranchPrefix + baseBranch
+ } else if baseIsTag {
+ baseBranchRef = git.TagPrefix + baseBranch
+ }
+ headBranchRef := headBranch
+ if headIsBranch {
+ headBranchRef = git.BranchPrefix + headBranch
+ } else if headIsTag {
+ headBranchRef = git.TagPrefix + headBranch
+ }
+
+ compareInfo, err := headGitRepo.GetCompareInfo(baseRepo.RepoPath(), baseBranchRef, headBranchRef)
if err != nil {
ctx.ServerError("GetCompareInfo", err)
return nil, nil, nil, nil, "", ""