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..dced07a0b8926f5b519de0461e393d5e79a26dbc 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,42 @@ class TryserverApi(recipe_api.RecipeApi): |
| failure_hash.hexdigest() |
| raise |
| + |
| + def get_tags(self, patch_text=None): |
|
tandrii(chromium)
2016/04/26 10:29:58
get_tags is confusing because 1) tag has different
martiniss
2016/04/29 21:34:40
good point, changed.
|
| + """Retrieves tags from the patch description. |
| + |
| + tags are lines with a format like |
| + FOO=arbitrary bar here |
| + It's used to annotate a CL with some machine readable data; for example, you |
| + can set BUG=123123 to tell bugdroid to update a bug when you close this CL. |
|
tandrii(chromium)
2016/04/26 10:29:58
iannucci@ gave us awesome footers support in depot
iannucci
2016/04/26 23:50:56
Yes, if we can use the footers format, that would
tandrii(chromium)
2016/04/27 13:06:13
Fix: https://chromereviews.googleplex.com/41285701
martiniss
2016/04/29 21:34:40
Ok, i'm switching to this style. Updating code app
|
| + """ |
| + if not patch_text: |
| + cmd = [self.m.depot_tools.git_cl_path, 'description'] |
| + |
| + codereview = None |
| + if not self.can_apply_issue: |
| + raise recipe_api.StepFailure("Cannot get tags from gerrit yet.") |
|
tandrii(chromium)
2016/04/26 10:29:58
tbh, i don't understand why this doens't work for
martiniss
2016/04/29 21:34:40
It does, but I don't know how to generate the URL
|
| + else: |
| + codereview = 'rietveld' |
| + url = ( |
| + self.m.properties['rietveld'].strip('/') + '/' + |
| + str(self.m.properties['issue'])) |
| + |
| + cmd.extend([url, '-d', codereview]) |
| + patch_text = self.m.step('Get description', cmd).stdout |
|
tandrii(chromium)
2016/04/26 10:29:58
i'd add separate "get_cl_description" api with jus
iannucci
2016/04/26 23:50:56
git_cl.description, but yes +1
martiniss
2016/04/29 21:34:40
Done.
|
| + |
| + tags = collections.defaultdict(list) |
| + for line in patch_text.splitlines(): |
| + split = line.split('=', 1) |
| + if len(split) == 1: |
| + continue |
| + |
| + name, contents = split |
| + tags[name.upper()].append(contents) |
| + |
| + return tags |
| + |
| + def get_tag(self, tag, patch_text=None): |
| + """Gets a specific tag from a CL description""" |
| + return self.get_tags(patch_text).get(tag, []) |
| + |