Commit 8e0c8684 authored by David Eisner's avatar David Eisner Committed by Airat Shigapov

Also render commit titles in HipChat notifications

parent 3d034c15
...@@ -88,6 +88,10 @@ class HipchatService < Service ...@@ -88,6 +88,10 @@ class HipchatService < Service
end end
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) def create_push_message(push)
ref_type = Gitlab::Git.tag_ref?(push[:ref]) ? 'tag' : 'branch' ref_type = Gitlab::Git.tag_ref?(push[:ref]) ? 'tag' : 'branch'
ref = Gitlab::Git.ref_name(push[:ref]) ref = Gitlab::Git.ref_name(push[:ref])
...@@ -110,7 +114,7 @@ class HipchatService < Service ...@@ -110,7 +114,7 @@ class HipchatService < Service
message << "(<a href=\"#{project.web_url}/compare/#{before}...#{after}\">Compare changes</a>)" message << "(<a href=\"#{project.web_url}/compare/#{before}...#{after}\">Compare changes</a>)"
push[:commits].take(MAX_COMMITS).each do |commit| 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 end
if push[:commits].count > MAX_COMMITS if push[:commits].count > MAX_COMMITS
...@@ -126,7 +130,7 @@ class HipchatService < Service ...@@ -126,7 +130,7 @@ class HipchatService < Service
obj_attr = data[:object_attributes] obj_attr = data[:object_attributes]
obj_attr = HashWithIndifferentAccess.new(obj_attr) obj_attr = HashWithIndifferentAccess.new(obj_attr)
title = obj_attr[:title] title = render_line(obj_attr[:title])
state = obj_attr[:state] state = obj_attr[:state]
issue_iid = obj_attr[:iid] issue_iid = obj_attr[:iid]
issue_url = obj_attr[:url] issue_url = obj_attr[:url]
...@@ -150,7 +154,7 @@ class HipchatService < Service ...@@ -150,7 +154,7 @@ class HipchatService < Service
merge_request_id = obj_attr[:iid] merge_request_id = obj_attr[:iid]
state = obj_attr[:state] state = obj_attr[:state]
description = obj_attr[:description] 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_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>"
...@@ -165,7 +169,7 @@ class HipchatService < Service ...@@ -165,7 +169,7 @@ class HipchatService < Service
end end
def format_title(title) def format_title(title)
"<b>" + title.lines.first.chomp + "</b>" "<b>#{render_line(title)}</b>"
end end
def create_note_message(data) def create_note_message(data)
......
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