summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-02-12 23:53:29 +0000
committerStan Hu <stanhu@gmail.com>2018-02-12 23:53:29 +0000
commit71b20240f6c403efad8708cf88e514eb75194fd9 (patch)
tree2635a9b1a2e84fdc48c54626668a0a9e311acd81
parent201f53e96d26d4babfc6a4492576f873219d4e6f (diff)
downloadgitlab-ce-revert-5c08a591.tar.gz
Revert "Merge branch '40793-fix-mr-title-for-jira' into 'master'"revert-5c08a591
This reverts merge request !16491
-rw-r--r--app/services/merge_requests/build_service.rb30
-rw-r--r--changelogs/unreleased/40793-fix-mr-title-for-jira.yml5
-rw-r--r--spec/services/merge_requests/build_service_spec.rb58
3 files changed, 12 insertions, 81 deletions
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb
index 2ae855d078b..22b9b91a957 100644
--- a/app/services/merge_requests/build_service.rb
+++ b/app/services/merge_requests/build_service.rb
@@ -1,9 +1,7 @@
module MergeRequests
class BuildService < MergeRequests::BaseService
- include Gitlab::Utils::StrongMemoize
-
def execute
- @params_issue_iid = params.delete(:issue_iid)
+ @issue_iid = params.delete(:issue_iid)
self.merge_request = MergeRequest.new(params)
merge_request.compare_commits = []
@@ -125,7 +123,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
+ assign_title_from_issue
merge_request.title ||= source_branch.titleize.humanize
merge_request.title = wip_title if compare_commits.empty?
@@ -134,9 +132,9 @@ module MergeRequests
end
def append_closes_description
- return unless issue
+ return unless issue_iid
- closes_issue = "Closes #{issue.to_reference}"
+ closes_issue = "Closes ##{issue_iid}"
if description.present?
merge_request.description += closes_issue.prepend("\n\n")
@@ -156,27 +154,13 @@ module MergeRequests
end
def assign_title_from_issue
- return unless issue
-
- merge_request.title = "Resolve \"#{issue.title}\"" if issue.is_a?(Issue)
+ return unless issue && issue.is_a?(Issue)
- unless merge_request.title
- branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize
- merge_request.title = "Resolve #{issue_iid}"
- merge_request.title += " \"#{branch_title}\"" unless branch_title.empty?
- end
+ merge_request.title = "Resolve \"#{issue.title}\""
end
def issue_iid
- strong_memoize(:issue_iid) do
- @params_issue_iid || begin
- id = if target_project.external_issue_tracker
- source_branch.match(target_project.external_issue_reference_pattern).try(:[], 0)
- end
-
- id || source_branch.match(/\A(\d+)-/).try(:[], 1)
- end
- end
+ @issue_iid ||= source_branch.match(/\A(\d+)-/).try(:[], 1)
end
def issue
diff --git a/changelogs/unreleased/40793-fix-mr-title-for-jira.yml b/changelogs/unreleased/40793-fix-mr-title-for-jira.yml
deleted file mode 100644
index 69461510a87..00000000000
--- a/changelogs/unreleased/40793-fix-mr-title-for-jira.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: Prevent JIRA issue identifier from being humanized.
-merge_request: 16491
-author: Andrew McCallum
-type: fixed
diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb
index e56d335a7d6..cb4c3e72aa0 100644
--- a/spec/services/merge_requests/build_service_spec.rb
+++ b/spec/services/merge_requests/build_service_spec.rb
@@ -172,32 +172,11 @@ describe MergeRequests::BuildService do
end
end
- context 'branch starts with numeric characters followed by a hyphen with no issue tracker' do
+ 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(false)
- allow(project).to receive(:issues_enabled?).and_return(false)
- 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' do
- commit_description = commit_1.safe_message.split(/\n+/, 2).last
-
- expect(merge_request.description).to eq("#{commit_description}")
- end
- end
-
- context 'branch starts with JIRA-formatted external issue IID followed by a hyphen' do
- let(:source_branch) { 'EXMPL-12345-fix-issue' }
-
- before do
allow(project).to receive(:external_issue_tracker).and_return(true)
- allow(project).to receive(:issues_enabled?).and_return(false)
- allow(project).to receive(:external_issue_reference_pattern).and_return(IssueTrackerService.reference_pattern)
end
it 'uses the title of the commit as the title of the merge request' do
@@ -207,7 +186,7 @@ describe MergeRequests::BuildService do
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 EXMPL-12345")
+ expect(merge_request.description).to eq("#{commit_description}\n\nCloses #12345")
end
end
end
@@ -273,46 +252,19 @@ describe MergeRequests::BuildService do
end
end
- context 'branch starts with numeric characters followed by a hyphen with no issue tracker' do
+ 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(false)
- allow(project).to receive(:issues_enabled?).and_return(false)
- end
-
- it 'sets the title to the humanized branch title' do
- expect(merge_request.title).to eq('12345 fix issue')
- end
- end
-
- context 'branch starts with JIRA-formatted external issue IID' do
- let(:source_branch) { 'EXMPL-12345' }
-
- before do
allow(project).to receive(:external_issue_tracker).and_return(true)
- allow(project).to receive(:issues_enabled?).and_return(false)
- allow(project).to receive(:external_issue_reference_pattern).and_return(IssueTrackerService.reference_pattern)
end
it 'sets the title to the humanized branch title' do
- expect(merge_request.title).to eq('Resolve EXMPL-12345')
+ expect(merge_request.title).to eq('12345 fix issue')
end
it 'appends the closes text' do
- expect(merge_request.description).to eq('Closes EXMPL-12345')
- end
-
- context 'followed by hyphenated text' do
- let(:source_branch) { 'EXMPL-12345-fix-issue' }
-
- it 'sets the title to the humanized branch title' do
- expect(merge_request.title).to eq('Resolve EXMPL-12345 "Fix issue"')
- end
-
- it 'appends the closes text' do
- expect(merge_request.description).to eq('Closes EXMPL-12345')
- end
+ expect(merge_request.description).to eq('Closes #12345')
end
end
end