Skip to content

Commit ef89260

Browse files
zeripathshashvat-kedialafriks
authored
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 <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 315d928 commit ef89260

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

models/pull.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,16 @@ func (pr *PullRequest) GetDefaultMergeMessage() string {
180180
return ""
181181
}
182182
}
183-
return fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.MustHeadUserName(), pr.HeadRepo.Name, pr.BaseBranch)
183+
if err := pr.LoadIssue(); err != nil {
184+
log.Error("Cannot load issue %d for PR id %d: Error: %v", pr.IssueID, pr.ID, err)
185+
return ""
186+
}
187+
188+
if pr.BaseRepoID == pr.HeadRepoID {
189+
return fmt.Sprintf("Merge pull request '%s' (#%d) from %s into %s", pr.Issue.Title, pr.Issue.Index, pr.HeadBranch, pr.BaseBranch)
190+
}
191+
192+
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)
184193
}
185194

186195
// GetCommitMessages returns the commit messages between head and merge base (if there is one)

0 commit comments

Comments
 (0)