From ef89260cf1235f85a6b400032e5b375e051c7902 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 15 Feb 2020 21:17:01 +0000 Subject: [PATCH] =?UTF-8?q?Repo=20name=20added=20to=20automatically=20gene?= =?UTF-8?q?rated=20commit=20message=20when=20mergin=E2=80=A6=20(#9997)=20(?= =?UTF-8?q?#10285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Repo name added to automatically generated commit message when merging pull request * As per @lunny Co-authored-by: Shashvat Kedia Co-authored-by: Lauris BH --- models/pull.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/models/pull.go b/models/pull.go index d165fde5f1b..ea9986dcf0a 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)