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