diff --git a/rhodecode/integrations/types/hipchat.py b/rhodecode/integrations/types/hipchat.py
--- a/rhodecode/integrations/types/hipchat.py
+++ b/rhodecode/integrations/types/hipchat.py
@@ -36,6 +36,26 @@ from rhodecode.integrations.types.base i
log = logging.getLogger(__name__)
+REPO_PUSH_TEMPLATE = Template('''
+${data['actor']['username']} pushed to repo ${data['repo']['repo_name']}:
+
+
+%for branch, branch_commits in branches_commits.items():
+ -
+ % if branch:
+ branch: ${branch_commits['branch']['name']}
+ % else:
+ to trunk
+ % endif
+
+ % for commit in branch_commits['commits']:
+ - ${commit['short_id']} - ${commit['message_html']}
+ % endfor
+
+
+%endfor
+''')
+
class HipchatSettingsSchema(colander.Schema):
color_choices = [
@@ -76,27 +96,6 @@ class HipchatSettingsSchema(colander.Sch
)
-repo_push_template = Template('''
-${data['actor']['username']} pushed to repo ${data['repo']['repo_name']}:
-
-
-%for branch, branch_commits in branches_commits.items():
- -
- % if branch:
- branch: ${branch_commits['branch']['name']}
- % else:
- to trunk
- % endif
-
- % for commit in branch_commits['commits']:
- - ${commit['short_id']} - ${commit['message_html']}
- % endfor
-
-
-%endfor
-''')
-
-
class HipchatIntegrationType(IntegrationTypeBase, CommitParsingDataHandler):
key = 'hipchat'
display_name = _('Hipchat')
@@ -226,7 +225,7 @@ class HipchatIntegrationType(Integration
data['push']['branches'], data['push']['commits'])
result = render_with_traceback(
- repo_push_template,
+ REPO_PUSH_TEMPLATE,
data=data,
branches_commits=branches_commits,
)
diff --git a/rhodecode/integrations/types/slack.py b/rhodecode/integrations/types/slack.py
--- a/rhodecode/integrations/types/slack.py
+++ b/rhodecode/integrations/types/slack.py
@@ -41,6 +41,30 @@ from rhodecode.integrations.types.base i
log = logging.getLogger(__name__)
+def html_to_slack_links(message):
+ return re.compile(r'(.+?)').sub(
+ r'<\1|\2>', message)
+
+
+REPO_PUSH_TEMPLATE = Template('''
+<%
+ def branch_text(branch):
+ if branch:
+ return 'on branch: <{}|{}>'.format(branch_commits['branch']['url'], branch_commits['branch']['name'])
+ else:
+ ## case for SVN no branch push...
+ return 'to trunk'
+%> \
+
+% for branch, branch_commits in branches_commits.items():
+${len(branch_commits['commits'])} ${'commit' if len(branch_commits['commits']) == 1 else 'commits'} ${branch_text(branch)}
+% for commit in branch_commits['commits']:
+`<${commit['url']}|${commit['short_id']}>` - ${commit['message_html']|html_to_slack_links}
+% endfor
+% endfor
+''')
+
+
class SlackSettingsSchema(colander.Schema):
service = colander.SchemaNode(
colander.String(),
@@ -258,7 +282,6 @@ class SlackIntegrationType(IntegrationTy
return title, text
def format_repo_push_event(self, data):
-
branches_commits = self.aggregate_branch_data(
data['push']['branches'], data['push']['commits'])
@@ -267,25 +290,8 @@ class SlackIntegrationType(IntegrationTy
''')
title = render_with_traceback(template, data=data)
- repo_push_template = Template(textwrap.dedent(r'''
- <%
- def branch_text(branch):
- if branch:
- return 'on branch: <{}|{}>'.format(branch_commits['branch']['url'], branch_commits['branch']['name'])
- else:
- ## case for SVN no branch push...
- return 'to trunk'
- %> \
- % for branch, branch_commits in branches_commits.items():
- ${len(branch_commits['commits'])} ${'commit' if len(branch_commits['commits']) == 1 else 'commits'} ${branch_text(branch)}
- % for commit in branch_commits['commits']:
- `<${commit['url']}|${commit['short_id']}>` - ${commit['message_html']|html_to_slack_links}
- % endfor
- % endfor
- '''))
-
text = render_with_traceback(
- repo_push_template,
+ REPO_PUSH_TEMPLATE,
data=data,
branches_commits=branches_commits,
html_to_slack_links=html_to_slack_links,
@@ -308,11 +314,6 @@ class SlackIntegrationType(IntegrationTy
return title, text
-def html_to_slack_links(message):
- return re.compile(r'(.+?)').sub(
- r'<\1|\2>', message)
-
-
@async_task(ignore_result=True, base=RequestContextTask)
def post_text_to_slack(settings, title, text, fields=None, overrides=None):
log.debug('sending %s (%s) to slack %s', title, text, settings['service'])