Chromium Code Reviews| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 self.add_failure_reason(e.reason) | 239 self.add_failure_reason(e.reason) |
| 239 | 240 |
| 240 failure_hash = hashlib.sha1() | 241 failure_hash = hashlib.sha1() |
| 241 failure_hash.update(self.m.json.dumps(self._failure_reasons)) | 242 failure_hash.update(self.m.json.dumps(self._failure_reasons)) |
| 242 | 243 |
| 243 step_result = self.m.step.active_result | 244 step_result = self.m.step.active_result |
| 244 step_result.presentation.properties['failure_hash'] = \ | 245 step_result.presentation.properties['failure_hash'] = \ |
| 245 failure_hash.hexdigest() | 246 failure_hash.hexdigest() |
| 246 | 247 |
| 247 raise | 248 raise |
| 249 | |
| 250 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.
| |
| 251 """Retrieves tags from the patch description. | |
| 252 | |
| 253 tags are lines with a format like | |
| 254 FOO=arbitrary bar here | |
| 255 It's used to annotate a CL with some machine readable data; for example, you | |
| 256 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
| |
| 257 """ | |
| 258 if not patch_text: | |
| 259 cmd = [self.m.depot_tools.git_cl_path, 'description'] | |
| 260 | |
| 261 codereview = None | |
| 262 if not self.can_apply_issue: | |
| 263 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
| |
| 264 else: | |
| 265 codereview = 'rietveld' | |
| 266 url = ( | |
| 267 self.m.properties['rietveld'].strip('/') + '/' + | |
| 268 str(self.m.properties['issue'])) | |
| 269 | |
| 270 cmd.extend([url, '-d', codereview]) | |
| 271 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.
| |
| 272 | |
| 273 tags = collections.defaultdict(list) | |
| 274 for line in patch_text.splitlines(): | |
| 275 split = line.split('=', 1) | |
| 276 if len(split) == 1: | |
| 277 continue | |
| 278 | |
| 279 name, contents = split | |
| 280 tags[name.upper()].append(contents) | |
| 281 | |
| 282 return tags | |
| 283 | |
| 284 def get_tag(self, tag, patch_text=None): | |
| 285 """Gets a specific tag from a CL description""" | |
| 286 return self.get_tags(patch_text).get(tag, []) | |
| 287 | |
| OLD | NEW |