Update emails to describe path using for_fork?

Forked MR's will print

Project:Branch <source_project_with_path>:<source_branch> -> <target_project_with_path>:<target_branch>

Non forked MR's will print

Branch <source_branch> -> <target_branch>

Change-Id: I89399aec2e7fde8e4b64b110a48099a95ae4f038
This commit is contained in:
Izaak Alpert 2013-07-17 10:35:11 -04:00
parent d99594273d
commit 539c70c7d6
9 changed files with 17 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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} &rarr; #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}
!= merge_path_description(@merge_request, '&rarr;')
%p
Assignee: #{@merge_request.author_name} &rarr; #{@merge_request.assignee_name}

View file

@ -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}

View file

@ -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} &rarr; #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}
!= merge_path_description(@merge_request, '&rarr;')
%p
Assignee: #{@merge_request.author_name} &rarr; #{@merge_request.assignee_name}

View file

@ -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}

View file

@ -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} &rarr; #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}
!= merge_path_description(@merge_request, '&rarr;')
%p
Assignee: #{@merge_request.author_name} &rarr; #{@merge_request.assignee_name}

View file

@ -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 %>