]> source.dussan.org Git - gitea.git/commitdiff
Repo name added to automatically generated commit message when mergin… (#9997) (...
authorzeripath <art27@cantab.net>
Sat, 15 Feb 2020 21:17:01 +0000 (21:17 +0000)
committerGitHub <noreply@github.com>
Sat, 15 Feb 2020 21:17:01 +0000 (21:17 +0000)
* 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>
models/pull.go

index d165fde5f1b9ef14dd56780266a7ad027073cd56..ea9986dcf0afd94864cc811183487cd93762dbe9 100644 (file)
@@ -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)