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 collections |
| 6 import contextlib | 6 import contextlib |
| 7 import hashlib | 7 import hashlib |
| 8 import os | |
| 9 import sys | |
| 10 import uuid | |
| 8 | 11 |
| 9 from recipe_engine import recipe_api | 12 from recipe_engine import recipe_api |
| 10 | 13 |
| 14 # Construct path to bot_update. | |
| 15 sys.path.append( | |
| 16 os.path.abspath( | |
| 17 os.path.join(os.path.realpath(__file__), os.pardir, os.pardir, | |
| 18 'bot_update', 'resources'))) | |
| 19 import bot_update | |
|
rmistry
2016/08/18 18:39:51
Did not want to duplicate all the work already don
tandrii(chromium)
2016/08/18 18:54:13
that's bad. And it's against the spirit of recipes
rmistry
2016/08/18 20:27:50
It does work (I tried it out locally).
Could I in
tandrii(chromium)
2016/08/18 20:30:09
That OR wdyt about adding new API in bot_update +
| |
| 11 | 20 |
| 12 PATCH_STORAGE_RIETVELD = 'rietveld' | 21 PATCH_STORAGE_RIETVELD = 'rietveld' |
| 22 PATCH_STORAGE_GERRIT = 'gerrit' | |
| 13 PATCH_STORAGE_GIT = 'git' | 23 PATCH_STORAGE_GIT = 'git' |
| 14 PATCH_STORAGE_SVN = 'svn' | 24 PATCH_STORAGE_SVN = 'svn' |
| 15 | 25 |
| 16 | 26 |
| 17 class TryserverApi(recipe_api.RecipeApi): | 27 class TryserverApi(recipe_api.RecipeApi): |
| 18 def __init__(self, *args, **kwargs): | 28 def __init__(self, *args, **kwargs): |
| 19 super(TryserverApi, self).__init__(*args, **kwargs) | 29 super(TryserverApi, self).__init__(*args, **kwargs) |
| 20 self._failure_reasons = [] | 30 self._failure_reasons = [] |
| 21 | 31 |
| 22 @property | 32 @property |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 def maybe_apply_issue(self, cwd=None, authentication=None): | 139 def maybe_apply_issue(self, cwd=None, authentication=None): |
| 130 """If we're a trybot, apply a codereview issue. | 140 """If we're a trybot, apply a codereview issue. |
| 131 | 141 |
| 132 Args: | 142 Args: |
| 133 cwd: If specified, apply the patch from the specified directory. | 143 cwd: If specified, apply the patch from the specified directory. |
| 134 authentication: authentication scheme whenever apply_issue.py is called. | 144 authentication: authentication scheme whenever apply_issue.py is called. |
| 135 This is only used if the patch comes from Rietveld. Possible values: | 145 This is only used if the patch comes from Rietveld. Possible values: |
| 136 None, 'oauth2' (see also api.rietveld.apply_issue.) | 146 None, 'oauth2' (see also api.rietveld.apply_issue.) |
| 137 """ | 147 """ |
| 138 storage = self.determine_patch_storage() | 148 storage = self.determine_patch_storage() |
| 139 | |
| 140 if storage == PATCH_STORAGE_RIETVELD: | 149 if storage == PATCH_STORAGE_RIETVELD: |
| 141 return self.m.rietveld.apply_issue( | 150 return self.m.rietveld.apply_issue( |
| 142 self.m.rietveld.calculate_issue_root(), | 151 self.m.rietveld.calculate_issue_root(), |
| 143 authentication=authentication) | 152 authentication=authentication) |
| 153 elif storage == PATCH_STORAGE_GERRIT: | |
| 154 patch_project = (self.m.properties.get('patch_project') or | |
| 155 self.m.properties.get('project')) | |
| 156 return bot_update.apply_gerrit_ref( | |
| 157 gerrit_repo=self.m.properties.get('repository') or 'origin', | |
| 158 gerrit_ref=self.m.properties.get('event.patchSet.ref'), | |
| 159 root=str(self.m.path['slave_build'].join(patch_project)), | |
| 160 gerrit_reset=True, | |
| 161 gerrit_rebase_patch_ref=True) | |
| 144 elif storage == PATCH_STORAGE_SVN: | 162 elif storage == PATCH_STORAGE_SVN: |
| 145 return self.apply_from_svn(cwd) | 163 return self.apply_from_svn(cwd) |
| 146 elif storage == PATCH_STORAGE_GIT: | 164 elif storage == PATCH_STORAGE_GIT: |
| 147 return self.apply_from_git(cwd) | 165 return self.apply_from_git(cwd) |
| 148 else: | 166 else: |
| 149 # Since this method is "maybe", we don't raise an Exception. | 167 # Since this method is "maybe", we don't raise an Exception. |
| 150 pass | 168 pass |
| 151 | 169 |
| 152 def get_files_affected_by_patch(self, patch_root=None, **kwargs): | 170 def get_files_affected_by_patch(self, patch_root=None, **kwargs): |
| 153 """Returns list of paths to files affected by the patch. | 171 """Returns list of paths to files affected by the patch. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 result = self.m.python( | 322 result = self.m.python( |
| 305 'parse description', self.package_repo_resource('git_footers.py'), | 323 'parse description', self.package_repo_resource('git_footers.py'), |
| 306 args=['--json', self.m.json.output()], | 324 args=['--json', self.m.json.output()], |
| 307 stdin=self.m.raw_io.input(data=patch_text)) | 325 stdin=self.m.raw_io.input(data=patch_text)) |
| 308 return result.json.output | 326 return result.json.output |
| 309 | 327 |
| 310 def get_footer(self, tag, patch_text=None): | 328 def get_footer(self, tag, patch_text=None): |
| 311 """Gets a specific tag from a CL description""" | 329 """Gets a specific tag from a CL description""" |
| 312 return self.get_footers(patch_text).get(tag, []) | 330 return self.get_footers(patch_text).get(tag, []) |
| 313 | 331 |
| OLD | NEW |