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 | 5 |
6 """Recipe module to ensure a checkout is consistant on a bot.""" | 6 """Recipe module to ensure a checkout is consistant on a bot.""" |
7 | 7 |
8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
9 | 9 |
10 | 10 |
11 class BotUpdateApi(recipe_api.RecipeApi): | 11 class BotUpdateApi(recipe_api.RecipeApi): |
12 | 12 |
13 def __init__(self, issue, patchset, repository, gerrit_ref, rietveld, | 13 def __init__(self, issue, patch_issue, patchset, patch_set, patch_project, |
14 revision, parent_got_revision, deps_revision_overrides, | 14 repository, patch_repository_url, gerrit_ref, patch_ref, |
15 fail_patch, *args, **kwargs): | 15 patch_gerrit_url, rietveld, revision, parent_got_revision, |
16 self._issue = issue | 16 deps_revision_overrides, fail_patch, *args, **kwargs): |
17 self._patchset = patchset | 17 self._issue = issue or patch_issue |
18 self._repository = repository | 18 self._patchset = patchset or patch_set |
19 self._gerrit_ref = gerrit_ref | 19 self._repository = repository or patch_repository_url |
| 20 self._gerrit_ref = gerrit_ref or patch_ref |
| 21 self._gerrit = patch_gerrit_url |
20 self._rietveld = rietveld | 22 self._rietveld = rietveld |
21 self._revision = revision | 23 self._revision = revision |
22 self._parent_got_revision = parent_got_revision | 24 self._parent_got_revision = parent_got_revision |
23 self._deps_revision_overrides = deps_revision_overrides | 25 self._deps_revision_overrides = deps_revision_overrides |
24 self._fail_patch = fail_patch | 26 self._fail_patch = fail_patch |
25 | 27 |
26 self._last_returned_properties = {} | 28 self._last_returned_properties = {} |
27 super(BotUpdateApi, self).__init__(*args, **kwargs) | 29 super(BotUpdateApi, self).__init__(*args, **kwargs) |
28 | 30 |
29 def __call__(self, name, cmd, **kwargs): | 31 def __call__(self, name, cmd, **kwargs): |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if issue: | 119 if issue: |
118 assert patchset | 120 assert patchset |
119 if patchset: | 121 if patchset: |
120 assert issue | 122 assert issue |
121 | 123 |
122 # The gerrit_ref and gerrit_repo must be together or not at all. If one is | 124 # The gerrit_ref and gerrit_repo must be together or not at all. If one is |
123 # missing, clear both of them. | 125 # missing, clear both of them. |
124 if not gerrit_ref or not gerrit_repo: | 126 if not gerrit_ref or not gerrit_repo: |
125 gerrit_repo = gerrit_ref = None | 127 gerrit_repo = gerrit_ref = None |
126 assert (gerrit_ref != None) == (gerrit_repo != None) | 128 assert (gerrit_ref != None) == (gerrit_repo != None) |
| 129 if gerrit_ref: |
| 130 # Gerrit patches have historically not specified issue and patchset. |
| 131 # resourece/bot_update has as a result implicit assumption that set issue |
| 132 # implies Rietveld patch. |
| 133 # TODO(tandrii): fix this madness. |
| 134 issue = patchset = None |
127 | 135 |
128 # Point to the oauth2 auth files if specified. | 136 # Point to the oauth2 auth files if specified. |
129 # These paths are where the bots put their credential files. | 137 # These paths are where the bots put their credential files. |
130 oauth2_json_file = email_file = key_file = None | 138 oauth2_json_file = email_file = key_file = None |
131 if oauth2_json: | 139 if oauth2_json: |
132 if self.m.platform.is_win: | 140 if self.m.platform.is_win: |
133 oauth2_json_file = 'C:\\creds\\refresh_tokens\\internal-try' | 141 oauth2_json_file = 'C:\\creds\\refresh_tokens\\internal-try' |
134 else: | 142 else: |
135 oauth2_json_file = '/creds/refresh_tokens/internal-try' | 143 oauth2_json_file = '/creds/refresh_tokens/internal-try' |
136 elif patch_oauth2: | 144 elif patch_oauth2: |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 300 |
293 # bot_update actually just sets root to be the folder name of the | 301 # bot_update actually just sets root to be the folder name of the |
294 # first solution. | 302 # first solution. |
295 if step_result.json.output['did_run']: | 303 if step_result.json.output['did_run']: |
296 co_root = step_result.json.output['root'] | 304 co_root = step_result.json.output['root'] |
297 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 305 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
298 if 'checkout' not in self.m.path: | 306 if 'checkout' not in self.m.path: |
299 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 307 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
300 | 308 |
301 return step_result | 309 return step_result |
OLD | NEW |