| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if gerrit_no_reset: | 59 if gerrit_no_reset: |
| 60 cmd.append('--gerrit_no_reset') | 60 cmd.append('--gerrit_no_reset') |
| 61 if gerrit_no_rebase_patch_ref: | 61 if gerrit_no_rebase_patch_ref: |
| 62 cmd.append('--gerrit_no_rebase_patch_ref') | 62 cmd.append('--gerrit_no_rebase_patch_ref') |
| 63 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) | 63 return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) |
| 64 | 64 |
| 65 def ensure_checkout(self, gclient_config=None, suffix=None, | 65 def ensure_checkout(self, gclient_config=None, suffix=None, |
| 66 patch=True, update_presentation=True, | 66 patch=True, update_presentation=True, |
| 67 patch_root=None, no_shallow=False, | 67 patch_root=None, no_shallow=False, |
| 68 with_branch_heads=False, refs=None, | 68 with_branch_heads=False, refs=None, |
| 69 patch_oauth2=False, oauth2_json=False, | 69 patch_oauth2=False, use_site_config_creds=True, |
| 70 use_site_config_creds=True, | |
| 71 output_manifest=True, clobber=False, | 70 output_manifest=True, clobber=False, |
| 72 root_solution_revision=None, rietveld=None, issue=None, | 71 root_solution_revision=None, rietveld=None, issue=None, |
| 73 patchset=None, gerrit_no_reset=False, | 72 patchset=None, gerrit_no_reset=False, |
| 74 gerrit_no_rebase_patch_ref=False, **kwargs): | 73 gerrit_no_rebase_patch_ref=False, **kwargs): |
| 75 """ | 74 """ |
| 76 Args: | 75 Args: |
| 77 use_site_config_creds: If the oauth2 credentials are in the buildbot | 76 use_site_config_creds: If the oauth2 credentials are in the buildbot |
| 78 site_config. See crbug.com/624212 for more information. | 77 site_config. See crbug.com/624212 for more information. |
| 79 gclient_config: The gclient configuration to use when running bot_update. | 78 gclient_config: The gclient configuration to use when running bot_update. |
| 80 If omitted, the current gclient configuration is used. | 79 If omitted, the current gclient configuration is used. |
| 81 rietveld: The rietveld server to use. If omitted, will infer from | 80 rietveld: The rietveld server to use. If omitted, will infer from |
| 82 the 'rietveld' property. | 81 the 'rietveld' property. |
| 83 issue: The rietveld issue number to use. If omitted, will infer from | 82 issue: The rietveld issue number to use. If omitted, will infer from |
| 84 the 'issue' property. | 83 the 'issue' property. |
| 85 patchset: The rietveld issue patchset to use. If omitted, will infer from | 84 patchset: The rietveld issue patchset to use. If omitted, will infer from |
| 86 the 'patchset' property. | 85 the 'patchset' property. |
| 87 """ | 86 """ |
| 88 refs = refs or [] | 87 refs = refs or [] |
| 89 # We can re-use the gclient spec from the gclient module, since all the | 88 # We can re-use the gclient spec from the gclient module, since all the |
| 90 # data bot_update needs is already configured into the gclient spec. | 89 # data bot_update needs is already configured into the gclient spec. |
| 91 cfg = gclient_config or self.m.gclient.c | 90 cfg = gclient_config or self.m.gclient.c |
| 92 assert cfg is not None, ( | 91 assert cfg is not None, ( |
| 93 'missing gclient_config or forgot api.gclient.set_config(...) before?') | 92 'missing gclient_config or forgot api.gclient.set_config(...) before?') |
| 94 | 93 |
| 95 # Only one of these should exist. | |
| 96 assert not (oauth2_json and patch_oauth2) | |
| 97 | |
| 98 # Construct our bot_update command. This basically be inclusive of | 94 # Construct our bot_update command. This basically be inclusive of |
| 99 # everything required for bot_update to know: | 95 # everything required for bot_update to know: |
| 100 root = patch_root | 96 root = patch_root |
| 101 if root is None: | 97 if root is None: |
| 102 root = self.m.gclient.calculate_patch_root( | 98 root = self.m.gclient.calculate_patch_root( |
| 103 self.m.properties.get('patch_project'), cfg) | 99 self.m.properties.get('patch_project'), cfg) |
| 104 | 100 |
| 105 if patch: | 101 if patch: |
| 106 issue = issue or self._issue | 102 issue = issue or self._issue |
| 107 patchset = patchset or self._patchset | 103 patchset = patchset or self._patchset |
| (...skipping 12 matching lines...) Expand all Loading... |
| 120 assert issue | 116 assert issue |
| 121 | 117 |
| 122 # The gerrit_ref and gerrit_repo must be together or not at all. If one is | 118 # The gerrit_ref and gerrit_repo must be together or not at all. If one is |
| 123 # missing, clear both of them. | 119 # missing, clear both of them. |
| 124 if not gerrit_ref or not gerrit_repo: | 120 if not gerrit_ref or not gerrit_repo: |
| 125 gerrit_repo = gerrit_ref = None | 121 gerrit_repo = gerrit_ref = None |
| 126 assert (gerrit_ref != None) == (gerrit_repo != None) | 122 assert (gerrit_ref != None) == (gerrit_repo != None) |
| 127 | 123 |
| 128 # Point to the oauth2 auth files if specified. | 124 # Point to the oauth2 auth files if specified. |
| 129 # These paths are where the bots put their credential files. | 125 # These paths are where the bots put their credential files. |
| 130 oauth2_json_file = email_file = key_file = None | 126 if patch_oauth2: |
| 131 if oauth2_json: | |
| 132 if self.m.platform.is_win: | |
| 133 oauth2_json_file = 'C:\\creds\\refresh_tokens\\rietveld.json' | |
| 134 else: | |
| 135 oauth2_json_file = '/creds/refresh_tokens/rietveld.json' | |
| 136 elif patch_oauth2: | |
| 137 # TODO(martiniss): remove this hack :(. crbug.com/624212 | 127 # TODO(martiniss): remove this hack :(. crbug.com/624212 |
| 138 if use_site_config_creds: | 128 if use_site_config_creds: |
| 139 email_file = self.m.path['build'].join( | 129 email_file = self.m.path['build'].join( |
| 140 'site_config', '.rietveld_client_email') | 130 'site_config', '.rietveld_client_email') |
| 141 key_file = self.m.path['build'].join( | 131 key_file = self.m.path['build'].join( |
| 142 'site_config', '.rietveld_secret_key') | 132 'site_config', '.rietveld_secret_key') |
| 143 else: #pragma: no cover | 133 else: #pragma: no cover |
| 144 #TODO(martiniss): make this use path.join, so it works on windows | 134 #TODO(martiniss): make this use path.join, so it works on windows |
| 145 email_file = '/creds/rietveld/client_email' | 135 email_file = '/creds/rietveld/client_email' |
| 146 key_file = '/creds/rietveld/secret_key' | 136 key_file = '/creds/rietveld/secret_key' |
| 137 else: |
| 138 email_file = key_file = None |
| 147 | 139 |
| 148 # Allow patch_project's revision if necessary. | 140 # Allow patch_project's revision if necessary. |
| 149 # This is important for projects which are checked out as DEPS of the | 141 # This is important for projects which are checked out as DEPS of the |
| 150 # gclient solution. | 142 # gclient solution. |
| 151 self.m.gclient.set_patch_project_revision( | 143 self.m.gclient.set_patch_project_revision( |
| 152 self.m.properties.get('patch_project'), cfg) | 144 self.m.properties.get('patch_project'), cfg) |
| 153 | 145 |
| 154 rev_map = cfg.got_revision_mapping.as_jsonish() | 146 rev_map = cfg.got_revision_mapping.as_jsonish() |
| 155 | 147 |
| 156 flags = [ | 148 flags = [ |
| 157 # What do we want to check out (spec/root/rev/rev_map). | 149 # What do we want to check out (spec/root/rev/rev_map). |
| 158 ['--spec', self.m.gclient.config_to_pythonish(cfg)], | 150 ['--spec', self.m.gclient.config_to_pythonish(cfg)], |
| 159 ['--patch_root', root], | 151 ['--patch_root', root], |
| 160 ['--revision_mapping_file', self.m.json.input(rev_map)], | 152 ['--revision_mapping_file', self.m.json.input(rev_map)], |
| 161 ['--git-cache-dir', cfg.cache_dir], | 153 ['--git-cache-dir', cfg.cache_dir], |
| 162 | 154 |
| 163 # How to find the patch, if any (issue/patchset). | 155 # How to find the patch, if any (issue/patchset). |
| 164 ['--issue', issue], | 156 ['--issue', issue], |
| 165 ['--patchset', patchset], | 157 ['--patchset', patchset], |
| 166 ['--rietveld_server', rietveld or self._rietveld], | 158 ['--rietveld_server', rietveld or self._rietveld], |
| 167 ['--gerrit_repo', gerrit_repo], | 159 ['--gerrit_repo', gerrit_repo], |
| 168 ['--gerrit_ref', gerrit_ref], | 160 ['--gerrit_ref', gerrit_ref], |
| 169 ['--apply_issue_email_file', email_file], | 161 ['--apply_issue_email_file', email_file], |
| 170 ['--apply_issue_key_file', key_file], | 162 ['--apply_issue_key_file', key_file], |
| 171 ['--apply_issue_oauth2_file', oauth2_json_file], | |
| 172 | 163 |
| 173 # Hookups to JSON output back into recipes. | 164 # Hookups to JSON output back into recipes. |
| 174 ['--output_json', self.m.json.output()],] | 165 ['--output_json', self.m.json.output()],] |
| 175 | 166 |
| 176 | 167 |
| 177 # Collect all fixed revisions to simulate them in the json output. | 168 # Collect all fixed revisions to simulate them in the json output. |
| 178 # Fixed revision are the explicit input revisions of bot_update.py, i.e. | 169 # Fixed revision are the explicit input revisions of bot_update.py, i.e. |
| 179 # every command line parameter "--revision name@value". | 170 # every command line parameter "--revision name@value". |
| 180 fixed_revisions = {} | 171 fixed_revisions = {} |
| 181 | 172 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 283 |
| 293 # bot_update actually just sets root to be the folder name of the | 284 # bot_update actually just sets root to be the folder name of the |
| 294 # first solution. | 285 # first solution. |
| 295 if step_result.json.output['did_run']: | 286 if step_result.json.output['did_run']: |
| 296 co_root = step_result.json.output['root'] | 287 co_root = step_result.json.output['root'] |
| 297 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 288 cwd = kwargs.get('cwd', self.m.path['slave_build']) |
| 298 if 'checkout' not in self.m.path: | 289 if 'checkout' not in self.m.path: |
| 299 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) | 290 self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep)) |
| 300 | 291 |
| 301 return step_result | 292 return step_result |
| OLD | NEW |