OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
| 5 import collections |
5 import contextlib | 6 import contextlib |
6 import hashlib | 7 import hashlib |
7 | 8 |
8 from recipe_engine import recipe_api | 9 from recipe_engine import recipe_api |
9 | 10 |
10 | 11 |
11 PATCH_STORAGE_RIETVELD = 'rietveld' | 12 PATCH_STORAGE_RIETVELD = 'rietveld' |
12 PATCH_STORAGE_GIT = 'git' | 13 PATCH_STORAGE_GIT = 'git' |
13 PATCH_STORAGE_SVN = 'svn' | 14 PATCH_STORAGE_SVN = 'svn' |
14 | 15 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 self.add_failure_reason(e.reason) | 272 self.add_failure_reason(e.reason) |
272 | 273 |
273 failure_hash = hashlib.sha1() | 274 failure_hash = hashlib.sha1() |
274 failure_hash.update(self.m.json.dumps(self._failure_reasons)) | 275 failure_hash.update(self.m.json.dumps(self._failure_reasons)) |
275 | 276 |
276 step_result = self.m.step.active_result | 277 step_result = self.m.step.active_result |
277 step_result.presentation.properties['failure_hash'] = \ | 278 step_result.presentation.properties['failure_hash'] = \ |
278 failure_hash.hexdigest() | 279 failure_hash.hexdigest() |
279 | 280 |
280 raise | 281 raise |
| 282 |
| 283 def get_footers(self, patch_text=None): |
| 284 """Retrieves footers from the patch description. |
| 285 |
| 286 footers are machine readable tags embedded in commit messages. See |
| 287 git-footers documentation for more information. |
| 288 """ |
| 289 if patch_text is None: |
| 290 codereview = None |
| 291 if not self.can_apply_issue: #pragma: no cover |
| 292 raise recipe_api.StepFailure("Cannot get tags from gerrit yet.") |
| 293 else: |
| 294 codereview = 'rietveld' |
| 295 patch = ( |
| 296 self.m.properties['rietveld'].strip('/') + '/' + |
| 297 str(self.m.properties['issue'])) |
| 298 |
| 299 patch_text = self.m.git_cl.get_description( |
| 300 patch=patch, codereview=codereview).stdout |
| 301 |
| 302 result = self.m.python( |
| 303 'parse description', self.package_repo_resource('git_footers.py'), |
| 304 args=['--json', self.m.json.output()], |
| 305 stdin=self.m.raw_io.input(data=patch_text)) |
| 306 return result.json.output |
| 307 |
| 308 def get_footer(self, tag, patch_text=None): |
| 309 """Gets a specific tag from a CL description""" |
| 310 return self.get_footers(patch_text).get(tag, []) |
| 311 |
OLD | NEW |