Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: recipe_modules/tryserver/api.py

Issue 1915833003: tryserver recipe_module: Add get_tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix copyright. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_footers(self, patch_text=None):
251 """Retrieves footers from the patch description.
252
253 footers are lines with a format like
254 Foo:arbitrary bar here
255 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
256 """
257 if not patch_text:
258 codereview = None
259 if not self.can_apply_issue: #pragma: no cover
260 raise recipe_api.StepFailure("Cannot get tags from gerrit yet.")
261 else:
262 codereview = 'rietveld'
263 patch = (
264 self.m.properties['rietveld'].strip('/') + '/' +
265 str(self.m.properties['issue']))
266
267 patch_text = self.m.git_cl.get_description(
268 patch=patch, codereview=codereview).stdout
269
270 tags = collections.defaultdict(list)
271 for line in patch_text.splitlines():
272 split = line.split(':', 1)
273 if len(split) == 1:
274 continue
275
276 name, contents = split
277 tags[name].append(contents)
278
279 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.
280
281 def get_footer(self, tag, patch_text=None):
282 """Gets a specific tag from a CL description"""
283 return self.get_footers(patch_text).get(tag, [])
284
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698