Commit 8d1b82ac authored by Ben Bodenmiller's avatar Ben Bodenmiller Committed by Yorick Peterse

format merge request references properly

parent f6fbd0fb
...@@ -87,6 +87,7 @@ v 8.7.0 (unreleased) ...@@ -87,6 +87,7 @@ v 8.7.0 (unreleased)
- Fix emoji categories in the emoji picker - Fix emoji categories in the emoji picker
- API: Properly display annotated tags for GET /projects/:id/repository/tags (Robert Schilling) - API: Properly display annotated tags for GET /projects/:id/repository/tags (Robert Schilling)
- Add encrypted credentials for imported projects and migrate old ones - Add encrypted credentials for imported projects and migrate old ones
- Properly format all merge request references with ! rather than # !3740 (Ben Bodenmiller)
- Author and participants are displayed first on users autocompletion - Author and participants are displayed first on users autocompletion
- Show number sign on external issue reference text (Florent Baldino) - Show number sign on external issue reference text (Florent Baldino)
- Updated print style for issues - Updated print style for issues
......
...@@ -56,7 +56,7 @@ module Emails ...@@ -56,7 +56,7 @@ module Emails
{ {
from: sender(sender_id), from: sender(sender_id),
to: recipient(recipient_id), to: recipient(recipient_id),
subject: subject("#{@merge_request.title} (##{@merge_request.iid})") subject: subject("#{@merge_request.title} (#{@merge_request.to_reference})")
} }
end end
end end
......
...@@ -38,7 +38,7 @@ module Emails ...@@ -38,7 +38,7 @@ module Emails
{ {
from: sender(@note.author_id), from: sender(@note.author_id),
to: recipient(recipient_id), to: recipient(recipient_id),
subject: subject("#{@note.noteable.title} (##{@note.noteable.iid})") subject: subject("#{@note.noteable.title} (#{@note.noteable.to_reference})")
} }
end end
......
...@@ -183,7 +183,7 @@ class HipchatService < Service ...@@ -183,7 +183,7 @@ class HipchatService < Service
title = obj_attr[:title] title = obj_attr[:title]
merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}" merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}"
merge_request_link = "<a href=\"#{merge_request_url}\">merge request ##{merge_request_id}</a>" merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>"
message = "#{user_name} #{state} #{merge_request_link} in " \ message = "#{user_name} #{state} #{merge_request_link} in " \
"#{project_link}: <b>#{title}</b>" "#{project_link}: <b>#{title}</b>"
...@@ -224,7 +224,7 @@ class HipchatService < Service ...@@ -224,7 +224,7 @@ class HipchatService < Service
when "MergeRequest" when "MergeRequest"
subj_attr = HashWithIndifferentAccess.new(data[:merge_request]) subj_attr = HashWithIndifferentAccess.new(data[:merge_request])
subject_id = subj_attr[:iid] subject_id = subj_attr[:iid]
subject_desc = "##{subject_id}" subject_desc = "!#{subject_id}"
subject_type = "merge request" subject_type = "merge request"
title = format_title(subj_attr[:title]) title = format_title(subj_attr[:title])
when "Snippet" when "Snippet"
......
...@@ -50,7 +50,7 @@ class SlackService ...@@ -50,7 +50,7 @@ class SlackService
end end
def merge_request_link def merge_request_link
"[merge request ##{merge_request_id}](#{merge_request_url})" "[merge request !#{merge_request_id}](#{merge_request_url})"
end end
def merge_request_url def merge_request_url
......
...@@ -58,7 +58,7 @@ class SlackService ...@@ -58,7 +58,7 @@ class SlackService
def create_merge_note(merge_request) def create_merge_note(merge_request)
commented_on_message( commented_on_message(
"[merge request ##{merge_request[:iid]}](#{@note_url})", "[merge request !#{merge_request[:iid]}](#{@note_url})",
format_title(merge_request[:title])) format_title(merge_request[:title]))
end end
......
%p %p
= "Merge Request ##{@merge_request.iid} was closed by #{@updated_by.name}" = "Merge Request #{@merge_request.to_reference} was closed by #{@updated_by.name}"
= "Merge Request ##{@merge_request.iid} was closed by #{@updated_by.name}" = "Merge Request #{@merge_request.to_reference} was closed by #{@updated_by.name}"
Merge Request url: #{namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)} Merge Request url: #{namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)}
......
%p %p
= "Merge Request ##{@merge_request.iid} was #{@mr_status} by #{@updated_by.name}" = "Merge Request #{@merge_request.to_reference} was #{@mr_status} by #{@updated_by.name}"
= "Merge Request ##{@merge_request.iid} was #{@mr_status} by #{@updated_by.name}" = "Merge Request #{@merge_request.to_reference} was #{@mr_status} by #{@updated_by.name}"
Merge Request url: #{namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)} Merge Request url: #{namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)}
......
%p %p
= "Merge Request ##{@merge_request.iid} was merged" = "Merge Request #{@merge_request.to_reference} was merged"
= "Merge Request ##{@merge_request.iid} was merged" = "Merge Request #{@merge_request.to_reference} was merged"
Merge Request url: #{namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)} Merge Request url: #{namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)}
......
New Merge Request #<%= @merge_request.iid %> New Merge Request <%= @merge_request.to_reference %>
<%= url_for(namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)) %> <%= url_for(namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request)) %>
......
New comment for Merge Request <%= @merge_request.iid %> New comment for Merge Request <%= @merge_request.to_reference %>
<%= url_for(namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, anchor: "note_#{@note.id}")) %> <%= url_for(namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, anchor: "note_#{@note.id}")) %>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
- merge_request = @build.merge_request - merge_request = @build.merge_request
- if merge_request - if merge_request
via via
= link_to "merge request ##{merge_request.iid}", merge_request_path(merge_request) = link_to "merge request #{merge_request.to_reference}", merge_request_path(merge_request)
#up-build-trace #up-build-trace
- builds = @build.commit.matrix_builds(@build) - builds = @build.commit.matrix_builds(@build)
......
- page_title "Edit", "#{@merge_request.title} (##{@merge_request.iid})", "Merge Requests" - page_title "Edit", "#{@merge_request.title} (#{@merge_request.to_reference}", "Merge Requests"
= render "header_title" = render "header_title"
%h3.page-title %h3.page-title
Edit Merge Request ##{@merge_request.iid} Edit Merge Request #{@merge_request.to_reference}
%hr %hr
= render 'form' = render 'form'
- page_title "#{@merge_request.title} (##{@merge_request.iid})", "Merge Requests" - page_title "#{@merge_request.title} (#{merge_request.to_reference}", "Merge Requests"
= render "header_title" = render "header_title"
.merge-request .merge-request
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
%h4 %h4
= link_to [merge_request.target_project.namespace.becomes(Namespace), merge_request.target_project, merge_request] do = link_to [merge_request.target_project.namespace.becomes(Namespace), merge_request.target_project, merge_request] do
%span.term.str-truncated= merge_request.title %span.term.str-truncated= merge_request.title
.pull-right ##{merge_request.iid} .pull-right #{merge_request.to_reference}
- if merge_request.description.present? - if merge_request.description.present?
.description.term .description.term
= preserve do = preserve do
......
...@@ -31,7 +31,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -31,7 +31,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
expect(page).to have_content 'Done 0' expect(page).to have_content 'Done 0'
expect(page).to have_link project.name_with_namespace expect(page).to have_link project.name_with_namespace
should_see_todo(1, "John Doe assigned you merge request !#{merge_request.iid}", merge_request.title) should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference}", merge_request.title)
should_see_todo(2, "John Doe mentioned you on issue ##{issue.iid}", "#{current_user.to_reference} Wdyt?") should_see_todo(2, "John Doe mentioned you on issue ##{issue.iid}", "#{current_user.to_reference} Wdyt?")
should_see_todo(3, "John Doe assigned you issue ##{issue.iid}", issue.title) should_see_todo(3, "John Doe assigned you issue ##{issue.iid}", issue.title)
should_see_todo(4, "Mary Jane mentioned you on issue ##{issue.iid}", issue.title) should_see_todo(4, "Mary Jane mentioned you on issue ##{issue.iid}", issue.title)
...@@ -45,7 +45,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -45,7 +45,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
page.within('.nav-sidebar') { expect(page).to have_content 'Todos 3' } page.within('.nav-sidebar') { expect(page).to have_content 'Todos 3' }
expect(page).to have_content 'To do 3' expect(page).to have_content 'To do 3'
expect(page).to have_content 'Done 1' expect(page).to have_content 'Done 1'
should_not_see_todo "John Doe assigned you merge request !#{merge_request.iid}" should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference}"
end end
step 'I click on the "Done" tab' do step 'I click on the "Done" tab' do
...@@ -54,7 +54,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -54,7 +54,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
step 'I should see all todos marked as done' do step 'I should see all todos marked as done' do
expect(page).to have_link project.name_with_namespace expect(page).to have_link project.name_with_namespace
should_see_todo(1, "John Doe assigned you merge request !#{merge_request.iid}", merge_request.title, false) should_see_todo(1, "John Doe assigned you merge request #{merge_request.to_reference}", merge_request.title, false)
end end
step 'I filter by "Enterprise"' do step 'I filter by "Enterprise"' do
...@@ -82,11 +82,11 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps ...@@ -82,11 +82,11 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
end end
step 'I should not see todos related to "Merge Requests" in the list' do step 'I should not see todos related to "Merge Requests" in the list' do
should_not_see_todo "John Doe assigned you merge request !#{merge_request.iid}" should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference}"
end end
step 'I should not see todos related to "Assignments" in the list' do step 'I should not see todos related to "Assignments" in the list' do
should_not_see_todo "John Doe assigned you merge request !#{merge_request.iid}" should_not_see_todo "John Doe assigned you merge request #{merge_request.to_reference}"
should_not_see_todo "John Doe assigned you issue ##{issue.iid}" should_not_see_todo "John Doe assigned you issue ##{issue.iid}"
end end
......
...@@ -114,7 +114,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -114,7 +114,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
step 'I see the edit page prefilled for "Merge Request On Forked Project"' do step 'I see the edit page prefilled for "Merge Request On Forked Project"' do
expect(current_path).to eq edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request) expect(current_path).to eq edit_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
expect(page).to have_content "Edit merge request ##{@merge_request.id}" expect(page).to have_content "Edit merge request #{@merge_request.to_reference}"
expect(find("#merge_request_title").value).to eq "Merge Request On Forked Project" expect(find("#merge_request_title").value).to eq "Merge Request On Forked Project"
end end
......
...@@ -213,7 +213,7 @@ describe Notify do ...@@ -213,7 +213,7 @@ describe Notify do
it_behaves_like 'an unsubscribeable thread' it_behaves_like 'an unsubscribeable thread'
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ is_expected.to have_subject /#{merge_request.title} \(#{merge_request.to_reference}\)/
end end
it 'contains a link to the new merge request' do it 'contains a link to the new merge request' do
...@@ -268,7 +268,7 @@ describe Notify do ...@@ -268,7 +268,7 @@ describe Notify do
end end
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ is_expected.to have_subject /#{merge_request.title} \(#{merge_request.to_reference}\)/
end end
it 'contains the name of the previous assignee' do it 'contains the name of the previous assignee' do
...@@ -302,7 +302,7 @@ describe Notify do ...@@ -302,7 +302,7 @@ describe Notify do
end end
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ is_expected.to have_subject /#{merge_request.title} \(#{merge_request.to_reference}\)/
end end
it 'contains the names of the added labels' do it 'contains the names of the added labels' do
...@@ -331,7 +331,7 @@ describe Notify do ...@@ -331,7 +331,7 @@ describe Notify do
end end
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i is_expected.to have_subject /#{merge_request.title} \(#{merge_request.to_reference}\)/i
end end
it 'contains the new status' do it 'contains the new status' do
...@@ -364,7 +364,7 @@ describe Notify do ...@@ -364,7 +364,7 @@ describe Notify do
end end
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ is_expected.to have_subject /#{merge_request.title} \(#{merge_request.to_reference}\)/
end end
it 'contains the new status' do it 'contains the new status' do
...@@ -502,7 +502,7 @@ describe Notify do ...@@ -502,7 +502,7 @@ describe Notify do
it_behaves_like 'an unsubscribeable thread' it_behaves_like 'an unsubscribeable thread'
it 'has the correct subject' do it 'has the correct subject' do
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ is_expected.to have_subject /#{merge_request.title} \(#{merge_request.to_reference}\)/
end end
it 'contains a link to the merge request note' do it 'contains a link to the merge request note' do
......
...@@ -152,7 +152,7 @@ describe HipchatService, models: true do ...@@ -152,7 +152,7 @@ describe HipchatService, models: true do
obj_attr = merge_sample_data[:object_attributes] obj_attr = merge_sample_data[:object_attributes]
expect(message).to eq("#{user.name} opened " \ expect(message).to eq("#{user.name} opened " \
"<a href=\"#{obj_attr[:url]}\">merge request ##{obj_attr["iid"]}</a> in " \ "<a href=\"#{obj_attr[:url]}\">merge request !#{obj_attr["iid"]}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \ "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>Awesome merge request</b>" \ "<b>Awesome merge request</b>" \
"<pre>please fix</pre>") "<pre>please fix</pre>")
...@@ -202,7 +202,7 @@ describe HipchatService, models: true do ...@@ -202,7 +202,7 @@ describe HipchatService, models: true do
title = data[:merge_request]['title'] title = data[:merge_request]['title']
expect(message).to eq("#{user.name} commented on " \ expect(message).to eq("#{user.name} commented on " \
"<a href=\"#{obj_attr[:url]}\">merge request ##{merge_id}</a> in " \ "<a href=\"#{obj_attr[:url]}\">merge request !#{merge_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \ "<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \ "<b>#{title}</b>" \
"<pre>merge request note</pre>") "<pre>merge request note</pre>")
......
...@@ -31,7 +31,7 @@ describe SlackService::MergeMessage, models: true do ...@@ -31,7 +31,7 @@ describe SlackService::MergeMessage, models: true do
context 'open' do context 'open' do
it 'returns a message regarding opening of merge requests' do it 'returns a message regarding opening of merge requests' do
expect(subject.pretext).to eq( expect(subject.pretext).to eq(
'Test User opened <somewhere.com/merge_requests/100|merge request #100> '\ 'Test User opened <somewhere.com/merge_requests/100|merge request !100> '\
'in <somewhere.com|project_name>: *Issue title*') 'in <somewhere.com|project_name>: *Issue title*')
expect(subject.attachments).to be_empty expect(subject.attachments).to be_empty
end end
...@@ -43,7 +43,7 @@ describe SlackService::MergeMessage, models: true do ...@@ -43,7 +43,7 @@ describe SlackService::MergeMessage, models: true do
end end
it 'returns a message regarding closing of merge requests' do it 'returns a message regarding closing of merge requests' do
expect(subject.pretext).to eq( expect(subject.pretext).to eq(
'Test User closed <somewhere.com/merge_requests/100|merge request #100> '\ 'Test User closed <somewhere.com/merge_requests/100|merge request !100> '\
'in <somewhere.com|project_name>: *Issue title*') 'in <somewhere.com|project_name>: *Issue title*')
expect(subject.attachments).to be_empty expect(subject.attachments).to be_empty
end end
......
...@@ -63,7 +63,7 @@ describe SlackService::NoteMessage, models: true do ...@@ -63,7 +63,7 @@ describe SlackService::NoteMessage, models: true do
it 'returns a message regarding notes on a merge request' do it 'returns a message regarding notes on a merge request' do
message = SlackService::NoteMessage.new(@args) message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq("Test User commented on " \ expect(message.pretext).to eq("Test User commented on " \
"<url|merge request #30> in <somewhere.com|project_name>: " \ "<url|merge request !30> in <somewhere.com|project_name>: " \
"*merge request title*") "*merge request title*")
expected_attachments = [ expected_attachments = [
{ {
......
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