BigW Consortium Gitlab

Commit 7f7cb2e6 by Grzegorz Bizon Committed by Tiago

Merge branch 'Ben305/gitlab-ce-36669-default-mr-title-with-external-issues' into 'master'

Resolve "Incorrect default merge request title when Jira activated" Closes #36669 See merge request gitlab-org/gitlab-ce!16356 (cherry picked from commit e7266441) 44c8f919 Fix incorrect default merge request title when external issue tracker is activated ca275561 Never set special MR titles for external issues f9cf2f99 Give appropriate credit to Ben305 in the changelog
parent 89a17180
......@@ -154,13 +154,9 @@ module MergeRequests
end
def assign_title_from_issue
return unless issue
return unless issue && issue.is_a?(Issue)
merge_request.title =
case issue
when Issue then "Resolve \"#{issue.title}\""
when ExternalIssue then "Resolve #{issue.title}"
end
merge_request.title = "Resolve \"#{issue.title}\""
end
def issue_iid
......
---
title: Default merge request title is set correctly again when external issue tracker is activated
merge_request: 16356
author: Ben305
type: fixed
......@@ -171,6 +171,24 @@ describe MergeRequests::BuildService do
end
end
end
context 'branch starts with external issue IID followed by a hyphen' do
let(:source_branch) { '12345-fix-issue' }
before do
allow(project).to receive(:external_issue_tracker).and_return(true)
end
it 'uses the title of the commit as the title of the merge request' do
expect(merge_request.title).to eq(commit_1.safe_message.split("\n").first)
end
it 'uses the description of the commit as the description of the merge request and appends the closes text' do
commit_description = commit_1.safe_message.split(/\n+/, 2).last
expect(merge_request.description).to eq("#{commit_description}\n\nCloses #12345")
end
end
end
context 'more than one commit in the diff' do
......@@ -241,8 +259,12 @@ describe MergeRequests::BuildService do
allow(project).to receive(:external_issue_tracker).and_return(true)
end
it 'sets the title to: Resolves External Issue $issue-iid' do
expect(merge_request.title).to eq('Resolve External Issue 12345')
it 'sets the title to the humanized branch title' do
expect(merge_request.title).to eq('12345 fix issue')
end
it 'appends the closes text' do
expect(merge_request.description).to eq('Closes #12345')
end
end
end
......
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