Browse Source

pull request: able to add custom commit description (#5276)

* pull request merges now allow for custom commit messages

* allow i18n on commit_message label

* place label above textarea for commit message

* rename commit message for pull requests into commit description and pass to git separately
pull/5317/head
ususdei 7 years ago committed by 无闻
parent
commit
cd71077c6a
  1. 1
      conf/locale/locale_en-US.ini
  2. 5
      models/pull.go
  3. 2
      routes/repo/pull.go
  4. 6
      templates/repo/issue/view_content.tmpl

1
conf/locale/locale_en-US.ini

@ -640,6 +640,7 @@ pulls.cannot_auto_merge_desc = This pull request can't be merged automatically b
pulls.cannot_auto_merge_helper = Please merge manually in order to resolve the conflicts.
pulls.create_merge_commit = Create a merge commit
pulls.rebase_before_merging = Rebase before merging
pulls.commit_description = Commit Description
pulls.merge_pull_request = Merge Pull Request
pulls.open_unmerged_pull_exists = `You can't perform reopen operation because there is already an open pull request (#%d) from same repository with same merge information and is waiting for merging.`
pulls.delete_branch = Delete Branch

5
models/pull.go

@ -193,7 +193,7 @@ const (
// Merge merges pull request to base repository.
// FIXME: add repoWorkingPull make sure two merges does not happen at same time.
func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle MergeStyle) (err error) {
func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle MergeStyle, CommitDescription string) (err error) {
defer func() {
go HookQueue.Add(pr.BaseRepo.ID)
go AddTestPullRequestTask(doer, pr.BaseRepo.ID, pr.BaseBranch, false)
@ -266,7 +266,8 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository, mergeStyle
if _, stderr, err = process.ExecDir(-1, tmpBasePath,
fmt.Sprintf("PullRequest.Merge (git merge): %s", tmpBasePath),
"git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
"-m", fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch)); err != nil {
"-m", fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch),
"-m", CommitDescription); err != nil {
return fmt.Errorf("git commit [%s]: %v - %s", tmpBasePath, err, stderr)
}

2
routes/repo/pull.go

@ -406,7 +406,7 @@ func MergePullRequest(c *context.Context) {
pr.Issue = issue
pr.Issue.Repo = c.Repo.Repository
if err = pr.Merge(c.User, c.Repo.GitRepo, models.MergeStyle(c.Query("merge_style"))); err != nil {
if err = pr.Merge(c.User, c.Repo.GitRepo, models.MergeStyle(c.Query("merge_style")), c.Query("commit_description")); err != nil {
c.ServerError("Merge", err)
return
}

6
templates/repo/issue/view_content.tmpl

@ -195,6 +195,12 @@
<div class="ui divider"></div>
<form class="ui form" action="{{.Link}}/merge" method="post">
{{.CSRFTokenHTML}}
<div class="field">
<div class="ui top">
<label>{{$.i18n.Tr "repo.pulls.commit_description"}}:</label>
<textarea id="commit_description" class="edit_area" name="commit_description" tabindex="4"></textarea>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input type="radio" name="merge_style" value="create_merge_commit" checked="checked">

Loading…
Cancel
Save