Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 itertools | 5 import itertools |
| 6 import re | 6 import re |
| 7 | 7 |
| 8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
| 9 | 9 |
| 10 class GitApi(recipe_api.RecipeApi): | 10 class GitApi(recipe_api.RecipeApi): |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 self.ensure_win_git_tooling() | 201 self.ensure_win_git_tooling() |
| 202 git_setup_args += [ | 202 git_setup_args += [ |
| 203 '--git_cmd_path', self.package_repo_resource('git.bat')] | 203 '--git_cmd_path', self.package_repo_resource('git.bat')] |
| 204 | 204 |
| 205 step_suffix = '' if step_suffix is None else ' (%s)' % step_suffix | 205 step_suffix = '' if step_suffix is None else ' (%s)' % step_suffix |
| 206 self.m.python( | 206 self.m.python( |
| 207 'git setup%s' % step_suffix, | 207 'git setup%s' % step_suffix, |
| 208 self.resource('git_setup.py'), | 208 self.resource('git_setup.py'), |
| 209 git_setup_args) | 209 git_setup_args) |
| 210 | 210 |
| 211 # Some of the commands below require depot_tools to be in PATH. | |
| 212 path = self.m.path.pathsep.join([ | |
| 213 str(self.package_repo_resource()), '%(PATH)s']) | |
|
nodir
2016/07/29 17:41:50
does %(PATH)s work? I don't know what expands it
borenet
2016/07/29 18:56:01
Yeah, must be the recipe engine. We use it in a c
| |
| 214 | |
| 211 if use_git_cache: | 215 if use_git_cache: |
| 212 self('retry', 'cache', 'fetch', '-c', self.m.path['git_cache'], | 216 self('retry', 'cache', 'fetch', '-c', self.m.path['git_cache'], |
| 213 cwd=dir_path, | 217 cwd=dir_path, |
| 214 name='fetch cache', | 218 name='fetch cache', |
| 215 can_fail_build=can_fail_build) | 219 can_fail_build=can_fail_build, |
| 220 env={'PATH': path}) | |
| 216 | 221 |
| 217 # There are five kinds of refs we can be handed: | 222 # There are five kinds of refs we can be handed: |
| 218 # 0) None. In this case, we default to properties['branch']. | 223 # 0) None. In this case, we default to properties['branch']. |
| 219 # 1) A 40-character SHA1 hash. | 224 # 1) A 40-character SHA1 hash. |
| 220 # 2) A fully-qualifed arbitrary ref, e.g. 'refs/foo/bar/baz'. | 225 # 2) A fully-qualifed arbitrary ref, e.g. 'refs/foo/bar/baz'. |
| 221 # 3) A fully qualified branch name, e.g. 'refs/heads/master'. | 226 # 3) A fully qualified branch name, e.g. 'refs/heads/master'. |
| 222 # Chop off 'refs/heads' and now it matches case (4). | 227 # Chop off 'refs/heads' and now it matches case (4). |
| 223 # 4) A branch name, e.g. 'master'. | 228 # 4) A branch name, e.g. 'master'. |
| 224 # Note that 'FETCH_HEAD' can be many things (and therefore not a valid | 229 # Note that 'FETCH_HEAD' can be many things (and therefore not a valid |
| 225 # checkout target) if many refs are fetched, but we only explicitly fetch | 230 # checkout target) if many refs are fetched, but we only explicitly fetch |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 239 checkout_ref = 'FETCH_HEAD' | 244 checkout_ref = 'FETCH_HEAD' |
| 240 else: # Cases 2 and 4. | 245 else: # Cases 2 and 4. |
| 241 fetch_remote = remote_name | 246 fetch_remote = remote_name |
| 242 fetch_ref = ref | 247 fetch_ref = ref |
| 243 checkout_ref = 'FETCH_HEAD' | 248 checkout_ref = 'FETCH_HEAD' |
| 244 | 249 |
| 245 fetch_args = [x for x in (fetch_remote, fetch_ref) if x] | 250 fetch_args = [x for x in (fetch_remote, fetch_ref) if x] |
| 246 if recursive: | 251 if recursive: |
| 247 fetch_args.append('--recurse-submodules') | 252 fetch_args.append('--recurse-submodules') |
| 248 | 253 |
| 249 fetch_env = {} | 254 fetch_env = {'PATH': path} |
| 250 fetch_stderr = None | 255 fetch_stderr = None |
| 251 if curl_trace_file: | 256 if curl_trace_file: |
| 252 fetch_env['GIT_CURL_VERBOSE'] = '1' | 257 fetch_env['GIT_CURL_VERBOSE'] = '1' |
| 253 fetch_stderr = self.m.raw_io.output(leak_to=curl_trace_file) | 258 fetch_stderr = self.m.raw_io.output(leak_to=curl_trace_file) |
| 254 | 259 |
| 255 fetch_step_name = 'git fetch%s' % step_suffix | 260 fetch_step_name = 'git fetch%s' % step_suffix |
| 256 if display_fetch_size: | 261 if display_fetch_size: |
| 257 count_objects_before_fetch = self.count_objects( | 262 count_objects_before_fetch = self.count_objects( |
| 258 name='count-objects before %s' % fetch_step_name, | 263 name='count-objects before %s' % fetch_step_name, |
| 259 cwd=dir_path, | 264 cwd=dir_path, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 | 389 |
| 385 Args: | 390 Args: |
| 386 bundle_path (Path): The path of the output bundle. | 391 bundle_path (Path): The path of the output bundle. |
| 387 refs (list): The list of refs to include in the bundle. If None, all | 392 refs (list): The list of refs to include in the bundle. If None, all |
| 388 refs in the Git checkout will be bundled. | 393 refs in the Git checkout will be bundled. |
| 389 kwargs: Forwarded to '__call__'. | 394 kwargs: Forwarded to '__call__'. |
| 390 """ | 395 """ |
| 391 if not rev_list_args: | 396 if not rev_list_args: |
| 392 rev_list_args = ['--all'] | 397 rev_list_args = ['--all'] |
| 393 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) | 398 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) |
| OLD | NEW |