aboutsummaryrefslogtreecommitdiffstats
path: root/models/pull.go
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@telenet.be>2021-02-18 03:45:49 +0100
committerGitHub <noreply@github.com>2021-02-18 03:45:49 +0100
commit4c82485424adb0fcf72cf9cde74596a7f0f54ada (patch)
tree97554f86469f5a6e7f6fd2f79f668a8ba7749e16 /models/pull.go
parent7ab6c77b4120d96b3239f827da8b858f65c36863 (diff)
downloadgitea-4c82485424adb0fcf72cf9cde74596a7f0f54ada.tar.gz
gitea-4c82485424adb0fcf72cf9cde74596a7f0f54ada.zip
#14699 Make branch names in PR description clickable (#14716)
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/models/pull.go b/models/pull.go
index 0d4691aac9..0eba65db4f 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
+ "code.gitea.io/gitea/modules/util"
)
// PullRequestType defines pull request type
@@ -638,3 +639,27 @@ func (pr *PullRequest) updateCommitDivergence(e Engine, ahead, behind int) error
func (pr *PullRequest) IsSameRepo() bool {
return pr.BaseRepoID == pr.HeadRepoID
}
+
+// GetBaseBranchHTMLURL returns the HTML URL of the base branch
+func (pr *PullRequest) GetBaseBranchHTMLURL() string {
+ if err := pr.LoadBaseRepo(); err != nil {
+ log.Error("LoadBaseRepo: %v", err)
+ return ""
+ }
+ if pr.BaseRepo == nil {
+ return ""
+ }
+ return pr.BaseRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.BaseBranch)
+}
+
+// GetHeadBranchHTMLURL returns the HTML URL of the head branch
+func (pr *PullRequest) GetHeadBranchHTMLURL() string {
+ if err := pr.LoadHeadRepo(); err != nil {
+ log.Error("LoadHeadRepo: %v", err)
+ return ""
+ }
+ if pr.HeadRepo == nil {
+ return ""
+ }
+ return pr.HeadRepo.HTMLURL() + "/src/branch/" + util.PathEscapeSegments(pr.HeadBranch)
+}