Commit 603ef5d4 authored by Gabriel Gizotti's avatar Gabriel Gizotti

Show either description or closes issues references on...

Show either description or closes issues references on MergeRequest#merge_commit_message so closes issues references are not duplicated
parent 99dd58ec
...@@ -633,18 +633,20 @@ class MergeRequest < ActiveRecord::Base ...@@ -633,18 +633,20 @@ class MergeRequest < ActiveRecord::Base
issue.to_reference(target_project) issue.to_reference(target_project)
end end
message = "Merge branch '#{source_branch}' into '#{target_branch}'\n\n" message = [
message << "#{title}\n\n" "Merge branch '#{source_branch}' into '#{target_branch}'",
title
]
if closes_issues_references.present? if !include_description && closes_issues_references.present?
issue_text = 'issue'.pluralize(closes_issues_references.size) issue_text = 'issue'.pluralize(closes_issues_references.size)
message << "Closes #{issue_text} #{closes_issues_references.to_sentence}\n\n" message << "Closes #{issue_text} #{closes_issues_references.to_sentence}"
end end
message << "#{description}\n\n" if include_description && description.present? message << "#{description}" if include_description && description.present?
message << "See merge request #{to_reference}" message << "See merge request #{to_reference}"
message message.join("\n\n")
end end
def reset_merge_when_build_succeeds def reset_merge_when_build_succeeds
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- elsif @merge_request.can_be_merged? || resolved_conflicts - elsif @merge_request.can_be_merged? || resolved_conflicts
= render 'projects/merge_requests/widget/open/accept' = render 'projects/merge_requests/widget/open/accept'
- if mr_closes_issues.present? || mr_issues_mentioned_but_not_closing - if mr_closes_issues.present? || mr_issues_mentioned_but_not_closing.present?
.mr-widget-footer .mr-widget-footer
%span %span
= icon('check') = icon('check')
...@@ -41,9 +41,7 @@ ...@@ -41,9 +41,7 @@
= mr_assign_issues_link = mr_assign_issues_link
- if mr_issues_mentioned_but_not_closing.present? - if mr_issues_mentioned_but_not_closing.present?
#{"Issue".pluralize(mr_issues_mentioned_but_not_closing.size)} #{"Issue".pluralize(mr_issues_mentioned_but_not_closing.size)}
= succeed '' do
!= markdown issues_sentence(mr_issues_mentioned_but_not_closing), pipeline: :gfm, author: @merge_request.author != markdown issues_sentence(mr_issues_mentioned_but_not_closing), pipeline: :gfm, author: @merge_request.author
= succeed '' do #{mr_issues_mentioned_but_not_closing.size > 1 ? 'are' : 'is'} mentioned but will not closed.
mentioned but will not closed.
...@@ -425,7 +425,7 @@ describe MergeRequest, models: true do ...@@ -425,7 +425,7 @@ describe MergeRequest, models: true do
and_return(subject.target_branch) and_return(subject.target_branch)
expect(subject.merge_commit_message) expect(subject.merge_commit_message)
.to match("Closed Issues: #{issue.to_reference}") .to match("Closes issue #{issue.to_reference}")
end end
it 'includes its reference in the body' do it 'includes its reference in the body' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment