diff options
Diffstat (limited to 'app/models/project_services')
3 files changed, 10 insertions, 2 deletions
diff --git a/app/models/project_services/chat_message/base_message.rb b/app/models/project_services/chat_message/base_message.rb index 8c68ddc40f2..6542112ba32 100644 --- a/app/models/project_services/chat_message/base_message.rb +++ b/app/models/project_services/chat_message/base_message.rb @@ -10,6 +10,7 @@ module ChatMessage attr_reader :user_avatar attr_reader :project_name attr_reader :project_url + attr_reader :commit_message_html def initialize(params) @markdown = params[:markdown] || false @@ -18,6 +19,7 @@ module ChatMessage @user_full_name = params.dig(:user, :name) || params[:user_full_name] @user_name = params.dig(:user, :username) || params[:user_name] @user_avatar = params.dig(:user, :avatar_url) || params[:user_avatar] + @commit_message_html = params[:commit_message_html] || false end def user_combined_name diff --git a/app/models/project_services/chat_message/push_message.rb b/app/models/project_services/chat_message/push_message.rb index 5dd0414b7e6..8163fca33a2 100644 --- a/app/models/project_services/chat_message/push_message.rb +++ b/app/models/project_services/chat_message/push_message.rb @@ -52,7 +52,8 @@ module ChatMessage end 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 def commit_message_attachments @@ -63,6 +64,11 @@ module ChatMessage author = commit[:author][:name] id = Commit.truncate_sha(commit[:id]) message = commit[:message] + + if commit_message_html + message = message.gsub(Gitlab::Regex.breakline_regex, "<br/>\n") + end + url = commit[:url] "[#{id}](#{url}): #{message} - #{author}" diff --git a/app/models/project_services/microsoft_teams_service.rb b/app/models/project_services/microsoft_teams_service.rb index c22a6dc26f6..2334b3f7f66 100644 --- a/app/models/project_services/microsoft_teams_service.rb +++ b/app/models/project_services/microsoft_teams_service.rb @@ -58,6 +58,6 @@ class MicrosoftTeamsService < ChatNotificationService end def custom_data(data) - super(data).merge(markdown: true) + super(data).merge(markdown: true, commit_message_html: true) end end |