summaryrefslogtreecommitdiffstats
path: root/models/pull.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-15 21:17:01 +0000
committerGitHub <noreply@github.com>2020-02-15 21:17:01 +0000
commitef89260cf1235f85a6b400032e5b375e051c7902 (patch)
tree3a7814758f287edf2fd36a0de2d9d4781b0c5987 /models/pull.go
parent315d928626cfed2e71ff4765f3379cdc78dab00c (diff)
downloadgitea-ef89260cf1235f85a6b400032e5b375e051c7902.tar.gz
gitea-ef89260cf1235f85a6b400032e5b375e051c7902.zip
Repo name added to automatically generated commit message when mergin… (#9997) (#10285)
* Repo name added to automatically generated commit message when merging pull request * As per @lunny Co-authored-by: Shashvat Kedia <sk261@snu.edu.in> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/pull.go')
-rw-r--r--models/pull.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/models/pull.go b/models/pull.go
index d165fde5f1..ea9986dcf0 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -180,7 +180,16 @@ func (pr *PullRequest) GetDefaultMergeMessage() string {
return ""
}
}
- return fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.MustHeadUserName(), pr.HeadRepo.Name, pr.BaseBranch)
+ if err := pr.LoadIssue(); err != nil {
+ log.Error("Cannot load issue %d for PR id %d: Error: %v", pr.IssueID, pr.ID, err)
+ return ""
+ }
+
+ if pr.BaseRepoID == pr.HeadRepoID {
+ return fmt.Sprintf("Merge pull request '%s' (#%d) from %s into %s", pr.Issue.Title, pr.Issue.Index, pr.HeadBranch, pr.BaseBranch)
+ }
+
+ return fmt.Sprintf("Merge pull request '%s' (#%d) from %s:%s into %s", pr.Issue.Title, pr.Issue.Index, pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseBranch)
}
// GetCommitMessages returns the commit messages between head and merge base (if there is one)