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