Commit d7553298 authored by phajdan.jr's avatar phajdan.jr Committed by Commit bot

git: fix git cache support

It's now based on bot_update logic.

BUG=630601

Review-Url: https://codereview.chromium.org/2209383002
parent 5c24f62d
...@@ -213,11 +213,23 @@ class GitApi(recipe_api.RecipeApi): ...@@ -213,11 +213,23 @@ class GitApi(recipe_api.RecipeApi):
str(self.package_repo_resource()), '%(PATH)s']) str(self.package_repo_resource()), '%(PATH)s'])
if use_git_cache: if use_git_cache:
self('retry', 'cache', 'fetch', '-c', self.m.path['git_cache'], with self.m.step.context({'env': {'PATH': path}}):
cwd=dir_path, self('retry', 'cache', 'populate', '-c', self.m.path['git_cache'], url,
name='fetch cache', name='populate cache',
can_fail_build=can_fail_build, can_fail_build=can_fail_build,
env={'PATH': path}) 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: # There are five kinds of refs we can be handed:
# 0) None. In this case, we default to properties['branch']. # 0) None. In this case, we default to properties['branch'].
......
...@@ -16,15 +16,47 @@ ...@@ -16,15 +16,47 @@
"git", "git",
"retry", "retry",
"cache", "cache",
"fetch", "populate",
"-c", "-c",
"[GIT_CACHE]" "[GIT_CACHE]",
"https://chromium.googlesource.com/chromium/src.git"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "populate cache"
},
{
"cmd": [
"git",
"cache",
"exists",
"--quiet",
"--cache-dir",
"[GIT_CACHE]",
"https://chromium.googlesource.com/chromium/src.git"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git cache",
"stdout": "/path/to/tmp/"
},
{
"cmd": [
"git",
"remote",
"set-url",
"origin",
"mirror_dir"
], ],
"cwd": "[SLAVE_BUILD]/src", "cwd": "[SLAVE_BUILD]/src",
"env": { "env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s" "PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
}, },
"name": "fetch cache" "name": "git remote"
}, },
{ {
"cmd": [ "cmd": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment