Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: recipe_modules/git/api.py

Issue 2209383002: git: fix git cache support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | recipe_modules/git/example.expected/git-cache-checkout.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 211 # Some of the commands below require depot_tools to be in PATH.
212 path = self.m.path.pathsep.join([ 212 path = self.m.path.pathsep.join([
213 str(self.package_repo_resource()), '%(PATH)s']) 213 str(self.package_repo_resource()), '%(PATH)s'])
214 214
215 if use_git_cache: 215 if use_git_cache:
216 self('retry', 'cache', 'fetch', '-c', self.m.path['git_cache'], 216 with self.m.step.context({'env': {'PATH': path}}):
217 cwd=dir_path, 217 self('retry', 'cache', 'populate', '-c', self.m.path['git_cache'], url,
218 name='fetch cache', 218 name='populate cache',
219 can_fail_build=can_fail_build, 219 can_fail_build=can_fail_build,
220 env={'PATH': path}) 220 cwd=dir_path)
221 dir_cmd = self(
222 'cache', 'exists', '--quiet',
223 '--cache-dir', self.m.path['git_cache'], url,
224 can_fail_build=can_fail_build,
225 stdout=self.m.raw_io.output(),
226 step_test_data=lambda:
227 self.m.raw_io.test_api.stream_output('mirror_dir'),
228 cwd=dir_path)
229 mirror_dir = dir_cmd.stdout.strip()
230 self('remote', 'set-url', 'origin', mirror_dir,
231 can_fail_build=can_fail_build,
232 cwd=dir_path)
221 233
222 # There are five kinds of refs we can be handed: 234 # There are five kinds of refs we can be handed:
223 # 0) None. In this case, we default to properties['branch']. 235 # 0) None. In this case, we default to properties['branch'].
224 # 1) A 40-character SHA1 hash. 236 # 1) A 40-character SHA1 hash.
225 # 2) A fully-qualifed arbitrary ref, e.g. 'refs/foo/bar/baz'. 237 # 2) A fully-qualifed arbitrary ref, e.g. 'refs/foo/bar/baz'.
226 # 3) A fully qualified branch name, e.g. 'refs/heads/master'. 238 # 3) A fully qualified branch name, e.g. 'refs/heads/master'.
227 # Chop off 'refs/heads' and now it matches case (4). 239 # Chop off 'refs/heads' and now it matches case (4).
228 # 4) A branch name, e.g. 'master'. 240 # 4) A branch name, e.g. 'master'.
229 # Note that 'FETCH_HEAD' can be many things (and therefore not a valid 241 # Note that 'FETCH_HEAD' can be many things (and therefore not a valid
230 # checkout target) if many refs are fetched, but we only explicitly fetch 242 # checkout target) if many refs are fetched, but we only explicitly fetch
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 401
390 Args: 402 Args:
391 bundle_path (Path): The path of the output bundle. 403 bundle_path (Path): The path of the output bundle.
392 refs (list): The list of refs to include in the bundle. If None, all 404 refs (list): The list of refs to include in the bundle. If None, all
393 refs in the Git checkout will be bundled. 405 refs in the Git checkout will be bundled.
394 kwargs: Forwarded to '__call__'. 406 kwargs: Forwarded to '__call__'.
395 """ 407 """
396 if not rev_list_args: 408 if not rev_list_args:
397 rev_list_args = ['--all'] 409 rev_list_args = ['--all']
398 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) 410 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs)
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/git/example.expected/git-cache-checkout.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698