Commit 8e2dec76 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'patch-28' into 'master'

Fix fallback logic for automatic MR title assignment

See merge request gitlab-org/gitlab-ce!20930
parents 76d9f556 00716350
......@@ -128,8 +128,7 @@ module MergeRequests
#
def assign_title_and_description
assign_title_and_description_from_single_commit
assign_title_from_issue if target_project.issues_enabled? || target_project.external_issue_tracker
merge_request.title ||= title_from_issue if target_project.issues_enabled? || target_project.external_issue_tracker
merge_request.title ||= source_branch.titleize.humanize
merge_request.title = wip_title if compare_commits.empty?
......@@ -159,20 +158,18 @@ module MergeRequests
merge_request.description ||= commit.description.try(:strip)
end
def assign_title_from_issue
def title_from_issue
return unless issue
merge_request.title = "Resolve \"#{issue.title}\"" if issue.is_a?(Issue)
return "Resolve \"#{issue.title}\"" if issue.is_a?(Issue)
return if merge_request.title.present?
return if issue_iid.blank?
if issue_iid.present?
title_parts = ["Resolve #{issue.to_reference}"]
branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize
title_parts << "\"#{branch_title}\"" if branch_title.present?
merge_request.title = title_parts.join(' ')
end
title_parts.join(' ')
end
def issue_iid
......
---
title: Fix fallback logic for automatic MR title assignment
merge_request: 20930
author: Franz Liedke
type: fixed
......@@ -169,6 +169,10 @@ describe MergeRequests::BuildService do
end
end
it 'uses the title of the commit as the title of the merge request' do
expect(merge_request.title).to eq('Initial commit')
end
it 'appends the closing description' do
expected_description = [commit_description, closing_message].compact.join("\n\n")
......
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