Show More
@@ -124,6 +124,7 b' class EEIntegration(IntegrationTypeBase)' | |||||
124 |
|
124 | |||
125 |
|
125 | |||
126 | # Helpers # |
|
126 | # Helpers # | |
|
127 | # updating this required to update the `common_vars` as well. | |||
127 | WEBHOOK_URL_VARS = [ |
|
128 | WEBHOOK_URL_VARS = [ | |
128 | ('event_name', 'Unique name of the event type, e.g pullrequest-update'), |
|
129 | ('event_name', 'Unique name of the event type, e.g pullrequest-update'), | |
129 | ('repo_name', 'Full name of the repository'), |
|
130 | ('repo_name', 'Full name of the repository'), | |
@@ -134,8 +135,9 b' WEBHOOK_URL_VARS = [' | |||||
134 | ('extra:<extra_key_name>', 'Extra repo variables, read from its settings.'), |
|
135 | ('extra:<extra_key_name>', 'Extra repo variables, read from its settings.'), | |
135 |
|
136 | |||
136 | # special attrs below that we handle, using multi-call |
|
137 | # special attrs below that we handle, using multi-call | |
137 | ('branch', 'Name of each brach submitted, if any.'), |
|
138 | ('branch', 'Name of each branch submitted, if any.'), | |
138 | ('commit_id', 'Id of each commit submitted, if any.'), |
|
139 | ('branch_head', 'Head ID of pushed branch (full sha of last commit), if any.'), | |
|
140 | ('commit_id', 'ID (full sha) of each commit submitted, if any.'), | |||
139 |
|
141 | |||
140 | # pr events vars |
|
142 | # pr events vars | |
141 | ('pull_request_id', 'Unique ID of the pull request.'), |
|
143 | ('pull_request_id', 'Unique ID of the pull request.'), | |
@@ -173,11 +175,13 b' class CommitParsingDataHandler(object):' | |||||
173 | _branch = branch_data[commit_branch] \ |
|
175 | _branch = branch_data[commit_branch] \ | |
174 | if commit_branch else commit_branch |
|
176 | if commit_branch else commit_branch | |
175 | branch_commits = {'branch': _branch, |
|
177 | branch_commits = {'branch': _branch, | |
|
178 | 'branch_head': '', | |||
176 | 'commits': []} |
|
179 | 'commits': []} | |
177 | branches_commits[commit_branch] = branch_commits |
|
180 | branches_commits[commit_branch] = branch_commits | |
178 |
|
181 | |||
179 | branch_commits = branches_commits[commit_branch] |
|
182 | branch_commits = branches_commits[commit_branch] | |
180 | branch_commits['commits'].append(commit) |
|
183 | branch_commits['commits'].append(commit) | |
|
184 | branch_commits['branch_head'] = commit['raw_id'] | |||
181 | return branches_commits |
|
185 | return branches_commits | |
182 |
|
186 | |||
183 |
|
187 | |||
@@ -218,10 +222,17 b' class WebhookDataHandler(CommitParsingDa' | |||||
218 |
|
222 | |||
219 | branches_commits = self.aggregate_branch_data( |
|
223 | branches_commits = self.aggregate_branch_data( | |
220 | data['push']['branches'], data['push']['commits']) |
|
224 | data['push']['branches'], data['push']['commits']) | |
221 | if '${branch}' in url: |
|
225 | if '${branch}' in url or '${branch_head}' in url: | |
222 | # call it multiple times, for each branch if used in variables |
|
226 | # call it multiple times, for each branch if used in variables | |
223 | for branch, commit_ids in branches_commits.items(): |
|
227 | for branch, commit_ids in branches_commits.items(): | |
224 | branch_url = string.Template(url).safe_substitute(branch=branch) |
|
228 | branch_url = string.Template(url).safe_substitute(branch=branch) | |
|
229 | ||||
|
230 | if '${branch_head}' in branch_url: | |||
|
231 | # last commit in the aggregate is the head of the branch | |||
|
232 | branch_head = commit_ids['branch_head'] | |||
|
233 | branch_url = string.Template(branch_url).safe_substitute( | |||
|
234 | branch_head=branch_head) | |||
|
235 | ||||
225 | # call further down for each commit if used |
|
236 | # call further down for each commit if used | |
226 | if '${commit_id}' in branch_url: |
|
237 | if '${commit_id}' in branch_url: | |
227 | for commit_data in commit_ids['commits']: |
|
238 | for commit_data in commit_ids['commits']: |
General Comments 0
You need to be logged in to leave comments.
Login now