Commit 5c2f2a67 authored by tandrii@chromium.org's avatar tandrii@chromium.org

Fix recipe module git to use package_resouce.

TBR=phajdan.jr@chromium.org,martiniss@chromium.org
BUG=590806

Review URL: https://codereview.chromium.org/1751003002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299027 0039d316-1c4b-4281-b951-d872f2087c98
parent 70a43af9
......@@ -10,6 +10,10 @@ from recipe_engine import recipe_api
class GitApi(recipe_api.RecipeApi):
_GIT_HASH_RE = re.compile('[0-9a-f]{40}', re.IGNORECASE)
def __init__(self, *args, **kwargs):
super(GitApi, self).__init__(*args, **kwargs)
self.initialized_win_git = False
def __call__(self, *args, **kwargs):
"""Return a git command step."""
name = kwargs.pop('name', 'git '+args[0])
......@@ -18,7 +22,8 @@ class GitApi(recipe_api.RecipeApi):
kwargs.setdefault('cwd', self.m.path['checkout'])
git_cmd = ['git']
if self.m.platform.is_win:
git_cmd = [self.m.path['depot_tools'].join('git.bat')]
self.ensure_win_git_tooling()
git_cmd = [self.package_resource('git.bat')]
options = kwargs.pop('git_config_options', {})
for k, v in sorted(options.iteritems()):
git_cmd.extend(['-c', '%s=%s' % (k, v)])
......@@ -32,6 +37,17 @@ class GitApi(recipe_api.RecipeApi):
else:
return f.result
def ensure_win_git_tooling(self):
"""Ensures that depot_tools/git.bat actually exists."""
if not self.m.platform.is_win or self.initialized_win_git:
return
self.m.step(
'ensure git tooling on windows',
[self.package_resource('bootstrap', 'win', 'win_tools.bat')],
infra_step=True,
cwd=self.package_resource())
self.initialized_win_git = True
def fetch_tags(self, remote_name=None, **kwargs):
"""Fetches all tags from the remote."""
kwargs.setdefault('name', 'git fetch tags')
......@@ -172,8 +188,8 @@ class GitApi(recipe_api.RecipeApi):
remote_name = 'origin'
if self.m.platform.is_win:
git_setup_args += ['--git_cmd_path',
self.m.path['depot_tools'].join('git.bat')]
self.ensure_win_git_tooling()
git_setup_args += ['--git_cmd_path', self.package_resource('git.bat')]
step_suffix = '' if step_suffix is None else ' (%s)' % step_suffix
self.m.python(
......
[
{
"cmd": [
"RECIPE_PACKAGE[depot_tools]\\bootstrap\\win\\win_tools.bat"
],
"cwd": "RECIPE_PACKAGE[depot_tools]",
"name": "ensure git tooling on windows"
},
{
"cmd": [
"python",
......@@ -9,14 +16,14 @@
"--url",
"https://chromium.googlesource.com/chromium/src.git",
"--git_cmd_path",
"[DEPOT_TOOLS]\\git.bat"
"RECIPE_PACKAGE[depot_tools]\\git.bat"
],
"cwd": "[SLAVE_BUILD]",
"name": "git setup"
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"retry",
"fetch",
"origin",
......@@ -28,7 +35,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"checkout",
"-f",
"FETCH_HEAD"
......@@ -38,7 +45,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"rev-parse",
"HEAD"
],
......@@ -51,7 +58,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"clean",
"-f",
"-d",
......@@ -62,7 +69,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"submodule",
"sync"
],
......@@ -71,7 +78,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"submodule",
"update",
"--init",
......@@ -82,7 +89,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"-c",
"foo=bar",
"count-objects",
......@@ -94,7 +101,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"config",
"--get",
"remote.origin.url"
......@@ -108,7 +115,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"show",
"HEAD",
"--format=%at",
......@@ -120,7 +127,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"fetch",
"origin",
"--tags"
......@@ -130,7 +137,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"status"
],
"cwd": "[SLAVE_BUILD]\\src",
......@@ -138,7 +145,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"status"
],
"cwd": "[SLAVE_BUILD]\\src",
......@@ -146,7 +153,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"status"
],
"cwd": "[SLAVE_BUILD]\\src",
......@@ -154,7 +161,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"rebase",
"origin/master"
],
......@@ -163,7 +170,7 @@
},
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"bundle",
"create",
"[SLAVE_BUILD]\\all.bundle",
......
[
{
"cmd": [
"[DEPOT_TOOLS]\\git.bat",
"RECIPE_PACKAGE[depot_tools]\\bootstrap\\win\\win_tools.bat"
],
"cwd": "RECIPE_PACKAGE[depot_tools]",
"name": "ensure git tooling on windows"
},
{
"cmd": [
"RECIPE_PACKAGE[depot_tools]\\git.bat",
"diff",
"--cached",
"--name-only"
......
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