aboutsummaryrefslogtreecommitdiff
path: root/modules/context/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r--modules/context/repo.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 710cbbf6..fdde6b92 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -98,6 +98,16 @@ func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error) {
return editorconfig.ParseBytes(data)
}
+// PullRequestURL returns URL for composing a pull request.
+// This function does not check if the repository can actually compose a pull request.
+func (r *Repository) PullRequestURL(baseBranch, headBranch string) string {
+ repoLink := r.RepoLink
+ if r.PullRequest.BaseRepo != nil {
+ repoLink = r.PullRequest.BaseRepo.Link()
+ }
+ return fmt.Sprintf("%s/compare/%s...%s:%s", repoLink, baseBranch, r.Owner.Name, headBranch)
+}
+
func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
// Non-fork repository will not return error in this method.
if err := repo.GetBaseRepo(); err != nil {