Skip to content

Commit

Permalink
Repo name added to automatically generated commit message when mergin… (
Browse files Browse the repository at this point in the history
#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>
  • Loading branch information
3 people authored Feb 15, 2020
1 parent 315d928 commit ef89260
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ef89260

Please sign in to comment.