Commit 00716350 authored by Franz Liedke's avatar Franz Liedke

REFACTOR: Clarify assignment fallback chain

parent 72c0c534
...@@ -128,8 +128,7 @@ module MergeRequests ...@@ -128,8 +128,7 @@ module MergeRequests
# #
def assign_title_and_description def assign_title_and_description
assign_title_and_description_from_single_commit 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 ||= source_branch.titleize.humanize
merge_request.title = wip_title if compare_commits.empty? merge_request.title = wip_title if compare_commits.empty?
...@@ -159,19 +158,18 @@ module MergeRequests ...@@ -159,19 +158,18 @@ module MergeRequests
merge_request.description ||= commit.description.try(:strip) merge_request.description ||= commit.description.try(:strip)
end end
def assign_title_from_issue def title_from_issue
return unless 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? return if issue_iid.blank?
title_parts = ["Resolve #{issue.to_reference}"] title_parts = ["Resolve #{issue.to_reference}"]
branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize
title_parts << "\"#{branch_title}\"" if branch_title.present? title_parts << "\"#{branch_title}\"" if branch_title.present?
merge_request.title = title_parts.join(' ') title_parts.join(' ')
end end
def issue_iid def issue_iid
......
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