diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 0fb4709e9c3f3fcb9048b99ff2e856df6cb9bc1b..4ba48aa4339f144bd28be55b44a48c93d47364d0 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -33,4 +33,12 @@ module MergeRequestsHelper def ci_build_details_path merge_request merge_request.source_project.gitlab_ci_service.build_page(merge_request.last_commit.sha) end + + def merge_path_description(merge_request, separator) + if merge_request.for_fork? + "Project:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} #{separator} #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}" + else + "Branches: #{@merge_request.source_branch} #{separator} #{@merge_request.target_branch}" + end + end end diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 06ccce7f8959a7ed7c0631c559695962435369ea..cf6950966e128b2135889c02e01202fbc733ed71 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -23,7 +23,6 @@ module Emails end end - # Over rides default behavour to show source/target # Formats arguments into a String suitable for use as an email subject # @@ -63,4 +62,5 @@ module Emails subject << " | " + extra.join(' | ') if extra.present? subject end + end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index a5aa97ab13dfc0846171e2c19130720931079949..7890ca7793baa86258ba42690558aae2f98f8af8 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -6,6 +6,7 @@ class Notify < ActionMailer::Base add_template_helper ApplicationHelper add_template_helper GitlabMarkdownHelper + add_template_helper MergeRequestsHelper default_url_options[:host] = Gitlab.config.gitlab.host default_url_options[:protocol] = Gitlab.config.gitlab.protocol diff --git a/app/views/notify/closed_merge_request_email.html.haml b/app/views/notify/closed_merge_request_email.html.haml index 306c1ff8f60bd119fe29cfe23a96883b408e3123..c6b45b1710a65dfdc81a1c51c6a5887dc35c2057 100644 --- a/app/views/notify/closed_merge_request_email.html.haml +++ b/app/views/notify/closed_merge_request_email.html.haml @@ -1,9 +1,9 @@ %p = "Merge Request #{@merge_request.id} was closed by #{@updated_by.name}" %p - = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.project, @merge_request) + = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.target_project, @merge_request) %p - Projects:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} → #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch} + != merge_path_description(@merge_request, '→') %p Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} diff --git a/app/views/notify/closed_merge_request_email.text.haml b/app/views/notify/closed_merge_request_email.text.haml index 7cf066339c3659d574743e62d5f94657dac6faf2..9a5bce5915afdf7411c09cc2d6291fd0ee012ef2 100644 --- a/app/views/notify/closed_merge_request_email.text.haml +++ b/app/views/notify/closed_merge_request_email.text.haml @@ -2,7 +2,7 @@ Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} -Project:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} to #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch} += merge_path_description(@merge_request, 'to') Author: #{@merge_request.author_name} Assignee: #{@merge_request.assignee_name} diff --git a/app/views/notify/merged_merge_request_email.html.haml b/app/views/notify/merged_merge_request_email.html.haml index 4115adf1b42db15c366d81d29a1f26ba47785c84..e3ae41819f872f488b62d6f2c39a8a9642d4c4bd 100644 --- a/app/views/notify/merged_merge_request_email.html.haml +++ b/app/views/notify/merged_merge_request_email.html.haml @@ -3,7 +3,7 @@ %p = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.target_project, @merge_request) %p - Projects:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} → #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch} + != merge_path_description(@merge_request, '→') %p Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} diff --git a/app/views/notify/merged_merge_request_email.text.haml b/app/views/notify/merged_merge_request_email.text.haml index ca18d8f30e5fa02124e3448f74ef5fcf09abfbd8..fa9ef0a4b3216fe339dc4b9755da70b89aae0cbb 100644 --- a/app/views/notify/merged_merge_request_email.text.haml +++ b/app/views/notify/merged_merge_request_email.text.haml @@ -2,7 +2,7 @@ Merge Request Url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} -Project:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} to #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch} += merge_path_description(@merge_request, 'to') Author: #{@merge_request.author_name} Assignee: #{@merge_request.assignee_name} diff --git a/app/views/notify/new_merge_request_email.html.haml b/app/views/notify/new_merge_request_email.html.haml index 72546e00b158354e52e3667c724b4f11b6a995a7..3b060001e6bada597d6bc70687f0732b25f45b6b 100644 --- a/app/views/notify/new_merge_request_email.html.haml +++ b/app/views/notify/new_merge_request_email.html.haml @@ -3,7 +3,7 @@ %p = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.target_project, @merge_request) %p - Project:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} → #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch} + != merge_path_description(@merge_request, '→') %p Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} diff --git a/app/views/notify/new_merge_request_email.text.erb b/app/views/notify/new_merge_request_email.text.erb index 4c1a93f7dcc40a22c1c3085f2579baeb1fc885ca..5448c1088fe8ae1382519e0fc15f7d9dcca2d770 100644 --- a/app/views/notify/new_merge_request_email.text.erb +++ b/app/views/notify/new_merge_request_email.text.erb @@ -2,7 +2,7 @@ New Merge Request <%= @merge_request.id %> <%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %> -From: <%= @merge_request.source_project.path_with_namespace%>:<%= @merge_request.source_branch %> to <%= @merge_request.target_project.path_with_namespace%>:<%= @merge_request.target_branch %> + <%= merge_path_description(@merge_request, 'to') %> Author: <%= @merge_request.author_name %> Asignee: <%= @merge_request.assignee_name %>