1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-16 22:48:27 +00:00

Fix generating compare link (#21519) (#21530)

Fix #6318, backport #21519

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
Lunny Xiao
2022-10-21 20:59:27 +08:00
committed by GitHub
parent 675c14aba6
commit 556e2d5506
2 changed files with 14 additions and 1 deletions

View File

@@ -458,6 +458,19 @@ func NewFuncMap() []template.FuncMap {
return items
},
"HasPrefix": strings.HasPrefix,
"CompareLink": func(baseRepo, repo *repo_model.Repository, branchName string) string {
var curBranch string
if repo.ID != baseRepo.ID {
curBranch += fmt.Sprintf("%s/%s:", url.PathEscape(repo.OwnerName), url.PathEscape(repo.Name))
}
curBranch += util.PathEscapeSegments(branchName)
return fmt.Sprintf("%s/compare/%s...%s",
baseRepo.Link(),
util.PathEscapeSegments(baseRepo.DefaultBranch),
curBranch,
)
},
}}
}