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 | 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 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 if gerrit_no_reset: | 65 if gerrit_no_reset: |
| 66 cmd.append('--gerrit_no_reset') | 66 cmd.append('--gerrit_no_reset') |
| 67 if gerrit_no_rebase_patch_ref or not gerrit_rebase_patch_ref: | 67 if gerrit_no_rebase_patch_ref or not gerrit_rebase_patch_ref: |
| 68 cmd.append('--gerrit_no_rebase_patch_ref') | 68 cmd.append('--gerrit_no_rebase_patch_ref') |
| 69 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) | 69 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) |
| 70 | 70 |
| 71 def ensure_checkout(self, gclient_config=None, suffix=None, | 71 def ensure_checkout(self, gclient_config=None, suffix=None, |
| 72 patch=True, update_presentation=True, | 72 patch=True, update_presentation=True, |
| 73 force=False, patch_root=None, no_shallow=False, | 73 force=False, patch_root=None, no_shallow=False, |
| 74 with_branch_heads=False, refs=None, | 74 with_branch_heads=False, refs=None, |
| 75 patch_oauth2=False, use_site_config_creds=True, | 75 patch_oauth2=False, oauth2_json=False, |
| 76 use_site_config_creds=True, | |
| 76 output_manifest=True, clobber=False, | 77 output_manifest=True, clobber=False, |
| 77 root_solution_revision=None, rietveld=None, issue=None, | 78 root_solution_revision=None, rietveld=None, issue=None, |
| 78 patchset=None, gerrit_no_reset=False, | 79 patchset=None, gerrit_no_reset=False, |
| 79 gerrit_no_rebase_patch_ref=False, | 80 gerrit_no_rebase_patch_ref=False, |
| 80 gerrit_rebase_patch_ref=True, **kwargs): | 81 gerrit_rebase_patch_ref=True, **kwargs): |
| 81 """ | 82 """ |
| 82 Args: | 83 Args: |
| 83 use_site_config_creds: If the oauth2 credentials are in the buildbot | 84 use_site_config_creds: If the oauth2 credentials are in the buildbot |
| 84 site_config. See crbug.com/624212 for more information. | 85 site_config. See crbug.com/624212 for more information. |
| 85 gclient_config: The gclient configuration to use when running bot_update. | 86 gclient_config: The gclient configuration to use when running bot_update. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 issue = patchset = None | 133 issue = patchset = None |
| 133 | 134 |
| 134 # The gerrit_ref and gerrit_repo must be together or not at all. If one is | 135 # The gerrit_ref and gerrit_repo must be together or not at all. If one is |
| 135 # missing, clear both of them. | 136 # missing, clear both of them. |
| 136 if not gerrit_ref or not gerrit_repo: | 137 if not gerrit_ref or not gerrit_repo: |
| 137 gerrit_repo = gerrit_ref = None | 138 gerrit_repo = gerrit_ref = None |
| 138 assert (gerrit_ref != None) == (gerrit_repo != None) | 139 assert (gerrit_ref != None) == (gerrit_repo != None) |
| 139 | 140 |
| 140 # Point to the oauth2 auth files if specified. | 141 # Point to the oauth2 auth files if specified. |
| 141 # These paths are where the bots put their credential files. | 142 # These paths are where the bots put their credential files. |
| 142 if patch_oauth2: | 143 oauth2_json_file = email_file = key_file = None |
| 144 if oauth2_json: | |
| 145 if self.m.platform.is_win: | |
| 146 oauth2_json_file = 'C:\\creds\\refresh_tokens\\rietveld.json' | |
| 147 else: | |
| 148 oauth2_json_file = '/creds/refresh_tokens/rietveld.json' | |
| 149 elif patch_oauth2: | |
|
tandrii(chromium)
2016/09/01 15:49:33
since oauth2_json takes patch_oauth2, i'd add to t
Ryan Tseng
2016/09/19 19:01:27
Done.
| |
| 143 # TODO(martiniss): remove this hack :(. crbug.com/624212 | 150 # TODO(martiniss): remove this hack :(. crbug.com/624212 |
| 144 if use_site_config_creds: | 151 if use_site_config_creds: |
| 145 email_file = self.m.path['build'].join( | 152 email_file = self.m.path['build'].join( |
| 146 'site_config', '.rietveld_client_email') | 153 'site_config', '.rietveld_client_email') |
| 147 key_file = self.m.path['build'].join( | 154 key_file = self.m.path['build'].join( |
| 148 'site_config', '.rietveld_secret_key') | 155 'site_config', '.rietveld_secret_key') |
| 149 else: #pragma: no cover | 156 else: #pragma: no cover |
| 150 #TODO(martiniss): make this use path.join, so it works on windows | 157 #TODO(martiniss): make this use path.join, so it works on windows |
| 151 email_file = '/creds/rietveld/client_email' | 158 email_file = '/creds/rietveld/client_email' |
| 152 key_file = '/creds/rietveld/secret_key' | 159 key_file = '/creds/rietveld/secret_key' |
| 153 else: | |
| 154 email_file = key_file = None | |
| 155 | 160 |
| 156 # Allow patch_project's revision if necessary. | 161 # Allow patch_project's revision if necessary. |
| 157 # This is important for projects which are checked out as DEPS of the | 162 # This is important for projects which are checked out as DEPS of the |
| 158 # gclient solution. | 163 # gclient solution. |
| 159 self.m.gclient.set_patch_project_revision( | 164 self.m.gclient.set_patch_project_revision( |
| 160 self.m.properties.get('patch_project'), cfg) | 165 self.m.properties.get('patch_project'), cfg) |
| 161 | 166 |
| 162 rev_map = cfg.got_revision_mapping.as_jsonish() | 167 rev_map = cfg.got_revision_mapping.as_jsonish() |
| 163 | 168 |
| 164 flags = [ | 169 flags = [ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 175 | 180 |
| 176 # 3. How to find the patch, if any (issue/patchset/patch_url). | 181 # 3. How to find the patch, if any (issue/patchset/patch_url). |
| 177 ['--issue', issue], | 182 ['--issue', issue], |
| 178 ['--patchset', patchset], | 183 ['--patchset', patchset], |
| 179 ['--patch_url', patch_url], | 184 ['--patch_url', patch_url], |
| 180 ['--rietveld_server', rietveld or self._rietveld], | 185 ['--rietveld_server', rietveld or self._rietveld], |
| 181 ['--gerrit_repo', gerrit_repo], | 186 ['--gerrit_repo', gerrit_repo], |
| 182 ['--gerrit_ref', gerrit_ref], | 187 ['--gerrit_ref', gerrit_ref], |
| 183 ['--apply_issue_email_file', email_file], | 188 ['--apply_issue_email_file', email_file], |
| 184 ['--apply_issue_key_file', key_file], | 189 ['--apply_issue_key_file', key_file], |
| 190 ['--apply_issue_oauth2_file', oauth2_json_file], | |
| 185 | 191 |
| 186 # 4. Hookups to JSON output back into recipes. | 192 # 4. Hookups to JSON output back into recipes. |
| 187 ['--output_json', self.m.json.output()],] | 193 ['--output_json', self.m.json.output()],] |
| 188 | 194 |
| 189 | 195 |
| 190 # Collect all fixed revisions to simulate them in the json output. | 196 # Collect all fixed revisions to simulate them in the json output. |
| 191 # Fixed revision are the explicit input revisions of bot_update.py, i.e. | 197 # Fixed revision are the explicit input revisions of bot_update.py, i.e. |
| 192 # every command line parameter "--revision name@value". | 198 # every command line parameter "--revision name@value". |
| 193 fixed_revisions = {} | 199 fixed_revisions = {} |
| 194 | 200 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 | 314 |
| 309 # bot_update actually just sets root to be the folder name of the | 315 # bot_update actually just sets root to be the folder name of the |
| 310 # first solution. | 316 # first solution. |
| 311 if step_result.json.output['did_run']: | 317 if step_result.json.output['did_run']: |
| 312 co_root = step_result.json.output['root'] | 318 co_root = step_result.json.output['root'] |
| 313 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 319 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
| 314 if 'checkout' not in self.m.path: | 320 if 'checkout' not in self.m.path: |
| 315 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 321 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
| 316 | 322 |
| 317 return step_result | 323 return step_result |
| OLD | NEW |