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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_modules/git/example.expected/git-cache-checkout.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/git/api.py
diff --git a/recipe_modules/git/api.py b/recipe_modules/git/api.py
index c2d4eb06ddf117c3854acdd969c2876561ae6d4a..d20f8a4dab1d57d1d0681e5a91d0e39b2da3b5ac 100644
--- a/recipe_modules/git/api.py
+++ b/recipe_modules/git/api.py
@@ -213,11 +213,23 @@ class GitApi(recipe_api.RecipeApi):
str(self.package_repo_resource()), '%(PATH)s'])
if use_git_cache:
- self('retry', 'cache', 'fetch', '-c', self.m.path['git_cache'],
- cwd=dir_path,
- name='fetch cache',
- can_fail_build=can_fail_build,
- env={'PATH': path})
+ with self.m.step.context({'env': {'PATH': path}}):
+ self('retry', 'cache', 'populate', '-c', self.m.path['git_cache'], url,
+ name='populate cache',
+ can_fail_build=can_fail_build,
+ cwd=dir_path)
+ dir_cmd = self(
+ 'cache', 'exists', '--quiet',
+ '--cache-dir', self.m.path['git_cache'], url,
+ can_fail_build=can_fail_build,
+ stdout=self.m.raw_io.output(),
+ step_test_data=lambda:
+ self.m.raw_io.test_api.stream_output('mirror_dir'),
+ cwd=dir_path)
+ mirror_dir = dir_cmd.stdout.strip()
+ self('remote', 'set-url', 'origin', mirror_dir,
+ can_fail_build=can_fail_build,
+ cwd=dir_path)
# There are five kinds of refs we can be handed:
# 0) None. In this case, we default to properties['branch'].
« 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