diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 7bd2bc0a1c..a723291440 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -459,6 +459,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,
+ )
+ },
}}
}
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index 39e58d8e0f..1e82d97944 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -70,7 +70,7 @@
{{if eq $n 0}}
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
-
+
{{end}}