Show More
@@ -78,22 +78,19 b' class HipchatSettingsSchema(colander.Sch' | |||||
78 |
|
78 | |||
79 |
|
79 | |||
80 | repo_push_template = Template(''' |
|
80 | repo_push_template = Template(''' | |
81 | <b>${data['actor']['username']}</b> pushed to |
|
81 | <b>${data['actor']['username']}</b> pushed to repo <a href="${data['repo']['url']}">${data['repo']['repo_name']}</a>: | |
82 | %if data['push']['branches']: |
|
|||
83 | ${len(data['push']['branches']) > 1 and 'branches' or 'branch'} |
|
|||
84 | ${', '.join('<a href="%s">%s</a>' % (branch['url'], branch['name']) for branch in data['push']['branches'])} |
|
|||
85 | %else: |
|
|||
86 | unknown branch |
|
|||
87 | %endif |
|
|||
88 | in <a href="${data['repo']['url']}">${data['repo']['repo_name']}</a> |
|
|||
89 | <br> |
|
82 | <br> | |
90 | <ul> |
|
83 | <ul> | |
91 | %for commit in data['push']['commits']: |
|
84 | %for branch, branch_commits in branches_commits.items(): | |
92 | <li> |
|
85 | <li> | |
93 | <a href="${commit['url']}">${commit['short_id']}</a> - ${commit['message_html']} |
|
86 | <a href="${branch_commits['branch']['url']}">branch: ${branch_commits['branch']['name']}</a> | |
|
87 | <ul> | |||
|
88 | %for commit in branch_commits['commits']: | |||
|
89 | <li><a href="${commit['url']}">${commit['short_id']}</a> - ${commit['message_html']}</li> | |||
|
90 | %endfor | |||
|
91 | </ul> | |||
94 | </li> |
|
92 | </li> | |
95 | %endfor |
|
93 | %endfor | |
96 | </ul> |
|
|||
97 | ''') |
|
94 | ''') | |
98 |
|
95 | |||
99 |
|
96 | |||
@@ -218,8 +215,23 b' class HipchatIntegrationType(Integration' | |||||
218 | ) |
|
215 | ) | |
219 |
|
216 | |||
220 | def format_repo_push_event(self, data): |
|
217 | def format_repo_push_event(self, data): | |
|
218 | branch_data = {branch['name']: branch | |||
|
219 | for branch in data['push']['branches']} | |||
|
220 | ||||
|
221 | branches_commits = {} | |||
|
222 | for commit in data['push']['commits']: | |||
|
223 | log.critical(commit) | |||
|
224 | if commit['branch'] not in branches_commits: | |||
|
225 | branch_commits = {'branch': branch_data[commit['branch']], | |||
|
226 | 'commits': []} | |||
|
227 | branches_commits[commit['branch']] = branch_commits | |||
|
228 | ||||
|
229 | branch_commits = branches_commits[commit['branch']] | |||
|
230 | branch_commits['commits'].append(commit) | |||
|
231 | ||||
221 | result = repo_push_template.render( |
|
232 | result = repo_push_template.render( | |
222 | data=data, |
|
233 | data=data, | |
|
234 | branches_commits=branches_commits, | |||
223 | ) |
|
235 | ) | |
224 | return result |
|
236 | return result | |
225 |
|
237 |
@@ -86,23 +86,16 b' class SlackSettingsSchema(colander.Schem' | |||||
86 |
|
86 | |||
87 |
|
87 | |||
88 | repo_push_template = Template(r''' |
|
88 | repo_push_template = Template(r''' | |
89 | *${data['actor']['username']}* pushed to \ |
|
89 | *${data['actor']['username']}* pushed to repo <${data['repo']['url']}|${data['repo']['repo_name']}>: | |
90 | %if data['push']['branches']: |
|
90 | %for branch, branch_commits in branches_commits.items(): | |
91 | ${len(data['push']['branches']) > 1 and 'branches' or 'branch'} \ |
|
91 | branch: <${branch_commits['branch']['url']}|${branch_commits['branch']['name']}> | |
92 | ${', '.join('<%s|%s>' % (branch['url'], branch['name']) for branch in data['push']['branches'])} \ |
|
92 | %for commit in branch_commits['commits']: | |
93 | %else: |
|
93 | > <${commit['url']}|${commit['short_id']}> - ${commit['message_html']|html_to_slack_links} | |
94 | unknown branch \ |
|
94 | %endfor | |
95 | %endif |
|
|||
96 | in <${data['repo']['url']}|${data['repo']['repo_name']}> |
|
|||
97 | >>> |
|
|||
98 | %for commit in data['push']['commits']: |
|
|||
99 | <${commit['url']}|${commit['short_id']}> - ${commit['message_html']|html_to_slack_links} |
|
|||
100 | %endfor |
|
95 | %endfor | |
101 | ''') |
|
96 | ''') | |
102 |
|
97 | |||
103 |
|
98 | |||
104 |
|
||||
105 |
|
||||
106 | class SlackIntegrationType(IntegrationTypeBase): |
|
99 | class SlackIntegrationType(IntegrationTypeBase): | |
107 | key = 'slack' |
|
100 | key = 'slack' | |
108 | display_name = _('Slack') |
|
101 | display_name = _('Slack') | |
@@ -224,8 +217,23 b' class SlackIntegrationType(IntegrationTy' | |||||
224 | ) |
|
217 | ) | |
225 |
|
218 | |||
226 | def format_repo_push_event(self, data): |
|
219 | def format_repo_push_event(self, data): | |
|
220 | branch_data = {branch['name']: branch | |||
|
221 | for branch in data['push']['branches']} | |||
|
222 | ||||
|
223 | branches_commits = {} | |||
|
224 | for commit in data['push']['commits']: | |||
|
225 | log.critical(commit) | |||
|
226 | if commit['branch'] not in branches_commits: | |||
|
227 | branch_commits = {'branch': branch_data[commit['branch']], | |||
|
228 | 'commits': []} | |||
|
229 | branches_commits[commit['branch']] = branch_commits | |||
|
230 | ||||
|
231 | branch_commits = branches_commits[commit['branch']] | |||
|
232 | branch_commits['commits'].append(commit) | |||
|
233 | ||||
227 | result = repo_push_template.render( |
|
234 | result = repo_push_template.render( | |
228 | data=data, |
|
235 | data=data, | |
|
236 | branches_commits=branches_commits, | |||
229 | html_to_slack_links=html_to_slack_links, |
|
237 | html_to_slack_links=html_to_slack_links, | |
230 | ) |
|
238 | ) | |
231 | return result |
|
239 | return result |
General Comments 0
You need to be logged in to leave comments.
Login now