Chromium Code Reviews| Index: recipe_modules/tryserver/api.py |
| diff --git a/recipe_modules/tryserver/api.py b/recipe_modules/tryserver/api.py |
| index 8bd8df87f94bdfb68e7ad7f91ee0a15f54fec61a..1592095c41ed7982c2033d9cd2720cb9aa7f8f7d 100644 |
| --- a/recipe_modules/tryserver/api.py |
| +++ b/recipe_modules/tryserver/api.py |
| @@ -2,6 +2,7 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import collections |
| import contextlib |
| import hashlib |
| @@ -245,3 +246,39 @@ class TryserverApi(recipe_api.RecipeApi): |
| failure_hash.hexdigest() |
| raise |
| + |
| + def get_footers(self, patch_text=None): |
| + """Retrieves footers from the patch description. |
| + |
| + footers are lines with a format like |
| + Foo:arbitrary bar here |
| + These are used to annotate a CL with some machine readable data. |
|
iannucci
2016/05/12 00:25:52
This description is not accurate. Footers are extr
martiniss
2016/05/13 19:23:56
Ok, changed. I just moved to use git-footers, and
|
| + """ |
| + if not patch_text: |
| + codereview = None |
| + if not self.can_apply_issue: #pragma: no cover |
| + raise recipe_api.StepFailure("Cannot get tags from gerrit yet.") |
| + else: |
| + codereview = 'rietveld' |
| + patch = ( |
| + self.m.properties['rietveld'].strip('/') + '/' + |
| + str(self.m.properties['issue'])) |
| + |
| + patch_text = self.m.git_cl.get_description( |
| + patch=patch, codereview=codereview).stdout |
| + |
| + tags = collections.defaultdict(list) |
| + for line in patch_text.splitlines(): |
| + split = line.split(':', 1) |
| + if len(split) == 1: |
| + continue |
| + |
| + name, contents = split |
| + tags[name].append(contents) |
| + |
| + return tags |
|
iannucci
2016/05/12 00:25:52
wait... why not use `git-footers` for this? If nec
martiniss
2016/05/13 19:23:56
Done.
|
| + |
| + def get_footer(self, tag, patch_text=None): |
| + """Gets a specific tag from a CL description""" |
| + return self.get_footers(patch_text).get(tag, []) |
| + |