summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Eisner <david.eisner@oriel.oxon.org>2016-10-04 12:38:31 +0100
committerAirat Shigapov <contact@airatshigapov.com>2016-10-20 15:44:34 +0300
commit8e0c868436db61be8020356f4792cc79c2964363 (patch)
tree28940e685e69c59e4429bdd697e5cc601f21332e
parent3d034c15017b45611cb3e52744f09cc45c1c7bbe (diff)
downloadgitlab-ce-8e0c868436db61be8020356f4792cc79c2964363.tar.gz
Also render commit titles in HipChat notifications
-rw-r--r--app/models/project_services/hipchat_service.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index f4edbbbceb2..7d70452a70b 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -88,6 +88,10 @@ class HipchatService < Service
end
end
+ def render_line(text)
+ Banzai.render(text.lines.first.chomp, project: project, pipeline: :single_line) if text
+ end
+
def create_push_message(push)
ref_type = Gitlab::Git.tag_ref?(push[:ref]) ? 'tag' : 'branch'
ref = Gitlab::Git.ref_name(push[:ref])
@@ -110,7 +114,7 @@ class HipchatService < Service
message << "(<a href=\"#{project.web_url}/compare/#{before}...#{after}\">Compare changes</a>)"
push[:commits].take(MAX_COMMITS).each do |commit|
- message << "<br /> - #{commit[:message].lines.first} (<a href=\"#{commit[:url]}\">#{commit[:id][0..5]}</a>)"
+ message << "<br /> - #{render_line(commit[:message])} (<a href=\"#{commit[:url]}\">#{commit[:id][0..5]}</a>)"
end
if push[:commits].count > MAX_COMMITS
@@ -126,7 +130,7 @@ class HipchatService < Service
obj_attr = data[:object_attributes]
obj_attr = HashWithIndifferentAccess.new(obj_attr)
- title = obj_attr[:title]
+ title = render_line(obj_attr[:title])
state = obj_attr[:state]
issue_iid = obj_attr[:iid]
issue_url = obj_attr[:url]
@@ -150,7 +154,7 @@ class HipchatService < Service
merge_request_id = obj_attr[:iid]
state = obj_attr[:state]
description = obj_attr[:description]
- title = obj_attr[:title]
+ title = render_line(obj_attr[:title])
merge_request_url = "#{project_url}/merge_requests/#{merge_request_id}"
merge_request_link = "<a href=\"#{merge_request_url}\">merge request !#{merge_request_id}</a>"
@@ -165,7 +169,7 @@ class HipchatService < Service
end
def format_title(title)
- "<b>" + title.lines.first.chomp + "</b>"
+ "<b>#{render_line(title)}</b>"
end
def create_note_message(data)