Commit 715a2453 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents fd091a4e 937b2027
...@@ -10,6 +10,7 @@ module ChatMessage ...@@ -10,6 +10,7 @@ module ChatMessage
attr_reader :user_avatar attr_reader :user_avatar
attr_reader :project_name attr_reader :project_name
attr_reader :project_url attr_reader :project_url
attr_reader :commit_message_html
def initialize(params) def initialize(params)
@markdown = params[:markdown] || false @markdown = params[:markdown] || false
...@@ -18,6 +19,7 @@ module ChatMessage ...@@ -18,6 +19,7 @@ module ChatMessage
@user_full_name = params.dig(:user, :name) || params[:user_full_name] @user_full_name = params.dig(:user, :name) || params[:user_full_name]
@user_name = params.dig(:user, :username) || params[:user_name] @user_name = params.dig(:user, :username) || params[:user_name]
@user_avatar = params.dig(:user, :avatar_url) || params[:user_avatar] @user_avatar = params.dig(:user, :avatar_url) || params[:user_avatar]
@commit_message_html = params[:commit_message_html] || false
end end
def user_combined_name def user_combined_name
......
...@@ -52,7 +52,8 @@ module ChatMessage ...@@ -52,7 +52,8 @@ module ChatMessage
end end
def commit_messages def commit_messages
commits.map { |commit| compose_commit_message(commit) }.join("\n\n") linebreak_chars = commit_message_html ? "<br/>\n<br/>\n" : "\n\n"
commits.map { |commit| compose_commit_message(commit) }.join(linebreak_chars)
end end
def commit_message_attachments def commit_message_attachments
...@@ -63,6 +64,11 @@ module ChatMessage ...@@ -63,6 +64,11 @@ module ChatMessage
author = commit[:author][:name] author = commit[:author][:name]
id = Commit.truncate_sha(commit[:id]) id = Commit.truncate_sha(commit[:id])
message = commit[:message] message = commit[:message]
if commit_message_html
message = message.gsub(Gitlab::Regex.breakline_regex, "<br/>\n")
end
url = commit[:url] url = commit[:url]
"[#{id}](#{url}): #{message} - #{author}" "[#{id}](#{url}): #{message} - #{author}"
......
...@@ -58,6 +58,6 @@ class MicrosoftTeamsService < ChatNotificationService ...@@ -58,6 +58,6 @@ class MicrosoftTeamsService < ChatNotificationService
end end
def custom_data(data) def custom_data(data)
super(data).merge(markdown: true) super(data).merge(markdown: true, commit_message_html: true)
end end
end end
...@@ -5,8 +5,8 @@ module QuickActions ...@@ -5,8 +5,8 @@ module QuickActions
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
include Gitlab::QuickActions::Dsl include Gitlab::QuickActions::Dsl
include Gitlab::QuickActions::IssueActions include Gitlab::QuickActions::IssueActions
include Gitlab::QuickActions::IssueAndMergeRequestActions
include Gitlab::QuickActions::IssuableActions include Gitlab::QuickActions::IssuableActions
include Gitlab::QuickActions::IssueAndMergeRequestActions
include Gitlab::QuickActions::MergeRequestActions include Gitlab::QuickActions::MergeRequestActions
include Gitlab::QuickActions::CommitActions include Gitlab::QuickActions::CommitActions
include Gitlab::QuickActions::CommonActions include Gitlab::QuickActions::CommonActions
......
---
title: Quick action label must be first in issue comment
merge_request: 32367
author: Romain Maneschi
type: fixed
---
title: Wrong format on MS teams integration push events with multi line commit messages
merge_request: 32180
author: Massimeddu Cireddu
type: fixed
...@@ -46,7 +46,7 @@ module Gitlab ...@@ -46,7 +46,7 @@ module Gitlab
private private
def line_break_chars(line) def line_break_chars(line)
match = /\r\n|\r|\n/.match(line) match = Gitlab::Regex.breakline_regex.match(line)
match[0] if match match[0] if match
end end
end end
......
...@@ -115,6 +115,10 @@ module Gitlab ...@@ -115,6 +115,10 @@ module Gitlab
def jira_transition_id_regex def jira_transition_id_regex
@jira_transition_id_regex ||= /\d+/ @jira_transition_id_regex ||= /\d+/
end end
def breakline_regex
@breakline_regex ||= /\r\n|\r|\n/
end
end end
end end
......
...@@ -55,6 +55,23 @@ describe "User comments on issue", :js do ...@@ -55,6 +55,23 @@ describe "User comments on issue", :js do
expect(page.find('svg.mermaid')).to have_content escaped_content expect(page.find('svg.mermaid')).to have_content escaped_content
end end
it 'opens autocomplete menu for quick actions and have `/label` first choice' do
project.add_maintainer(user)
create(:label, project: project, title: 'label')
page.within '.timeline-content-form' do
find('#note-body').native.send_keys('/l')
end
wait_for_requests
expect(page).to have_selector('.atwho-container')
page.within '.atwho-container #at-view-commands' do
expect(find('li', match: :first)).to have_content('/label')
end
end
end end
context "when editing comments" do context "when editing comments" do
......
...@@ -23,7 +23,7 @@ describe ChatMessage::PushMessage do ...@@ -23,7 +23,7 @@ describe ChatMessage::PushMessage do
before do before do
args[:commits] = [ args[:commits] = [
{ message: 'message1', url: 'http://url1.com', id: 'abcdefghijkl', author: { name: 'author1' } }, { message: 'message1', url: 'http://url1.com', id: 'abcdefghijkl', author: { name: 'author1' } },
{ message: 'message2', url: 'http://url2.com', id: '123456789012', author: { name: 'author2' } } { message: "message2\nsecondline", url: 'http://url2.com', id: '123456789012', author: { name: 'author2' } }
] ]
end end
...@@ -34,7 +34,7 @@ describe ChatMessage::PushMessage do ...@@ -34,7 +34,7 @@ describe ChatMessage::PushMessage do
'<http://url.com|project_name> (<http://url.com/compare/before...after|Compare changes>)') '<http://url.com|project_name> (<http://url.com/compare/before...after|Compare changes>)')
expect(subject.attachments).to eq([{ expect(subject.attachments).to eq([{
text: "<http://url1.com|abcdefgh>: message1 - author1\n\n"\ text: "<http://url1.com|abcdefgh>: message1 - author1\n\n"\
"<http://url2.com|12345678>: message2 - author2", "<http://url2.com|12345678>: message2\nsecondline - author2",
color: color color: color
}]) }])
end end
...@@ -49,7 +49,27 @@ describe ChatMessage::PushMessage do ...@@ -49,7 +49,27 @@ describe ChatMessage::PushMessage do
expect(subject.pretext).to eq( expect(subject.pretext).to eq(
'test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))') 'test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))')
expect(subject.attachments).to eq( expect(subject.attachments).to eq(
"[abcdefgh](http://url1.com): message1 - author1\n\n[12345678](http://url2.com): message2 - author2") "[abcdefgh](http://url1.com): message1 - author1\n\n[12345678](http://url2.com): message2\nsecondline - author2")
expect(subject.activity).to eq(
title: 'test.user pushed to branch [master](http://url.com/commits/master)',
subtitle: 'in [project_name](http://url.com)',
text: '[Compare changes](http://url.com/compare/before...after)',
image: 'http://someavatar.com'
)
end
end
context 'with markdown and commit message html' do
before do
args[:commit_message_html] = true
args[:markdown] = true
end
it 'returns a message regarding pushes' do
expect(subject.pretext).to eq(
'test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))')
expect(subject.attachments).to eq(
"[abcdefgh](http://url1.com): message1 - author1<br/>\n<br/>\n[12345678](http://url2.com): message2<br/>\nsecondline - author2")
expect(subject.activity).to eq( expect(subject.activity).to eq(
title: 'test.user pushed to branch [master](http://url.com/commits/master)', title: 'test.user pushed to branch [master](http://url.com/commits/master)',
subtitle: 'in [project_name](http://url.com)', subtitle: 'in [project_name](http://url.com)',
......
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