From 926002fdf8d83147cfb577939bd3f8e75da56548 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 12 Feb 2018 17:29:28 -0800 Subject: Fix Error 500s creating merge requests with external issue tracker When JIRA or Redmine were enabled and the branch name did not match the matching regular expression, the `issue_iid` would be `nil`, preventing users from creating merge requests. Closes #43193 --- app/services/merge_requests/build_service.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/services') diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index 2ae855d078b..ab6f8ea44a9 100644 --- a/app/services/merge_requests/build_service.rb +++ b/app/services/merge_requests/build_service.rb @@ -160,10 +160,12 @@ module MergeRequests merge_request.title = "Resolve \"#{issue.title}\"" if issue.is_a?(Issue) - unless merge_request.title - branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize + return if merge_request.title.present? + + if issue_iid.present? merge_request.title = "Resolve #{issue_iid}" - merge_request.title += " \"#{branch_title}\"" unless branch_title.empty? + branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize + merge_request.title += " \"#{branch_title}\"" if branch_title.present? end end -- cgit v1.2.1