Add support to gclient for skipping CIPD deps.

I want to use this in the Codesearch builder to replace the hack in
crrev.com/c/1126693.

Bug: 860397
Change-Id: I174a684cbff0f993b5c657bc2e32105cb49d253a
Reviewed-on: https://chromium-review.googlesource.com/1132266
Commit-Queue: Joey Scarr <jsca@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
changes/66/1132266/6
Joey Scarr 7 years ago committed by Commit Bot
parent 2f38df65f9
commit 8d3925b164

@ -604,6 +604,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
should_process = should_process and gclient_eval.EvaluateCondition(
condition, self.get_vars())
# The following option is only set by the 'revinfo' command.
if self._get_option('ignore_dep_type', None) == dep_type:
continue
if dep_type == 'cipd':
cipd_root = self.GetCipdRoot()
for package in dep_value.get('packages', []):
@ -2711,6 +2715,8 @@ def CMDrevinfo(parser, args):
parser.add_option('--output-json',
help='Output a json document to this path containing '
'information about the revisions.')
parser.add_option('--ignore-dep-type', choices=['git', 'cipd'],
help='Specify to skip processing of a certain type of dep.')
(options, args) = parser.parse_args(args)
client = GClient.LoadCurrentConfig(options)
if not client:

@ -872,6 +872,48 @@ class GclientTest(trial_dir.TestCase):
],
self._get_processed())
def testIgnoresGitDependenciesWhenFlagIsSet(self):
"""Verifies that git deps are ignored if --ignore-dep-type git is set."""
write(
'.gclient',
'solutions = [\n'
' { "name": "foo", "url": "https://example.com/foo",\n'
' "deps_file" : ".DEPS.git",\n'
' },\n'
']')
write(
os.path.join('foo', 'DEPS'),
'vars = {\n'
' "lemur_version": "version:1234",\n'
'}\n'
'deps = {\n'
' "bar": "/bar",\n'
' "baz": {\n'
' "packages": [{\n'
' "package": "lemur",\n'
' "version": Var("lemur_version"),\n'
' }],\n'
' "dep_type": "cipd",\n'
' }\n'
'}')
options, _ = gclient.OptionParser().parse_args([])
options.ignore_dep_type = 'git'
options.validate_syntax = True
obj = gclient.GClient.LoadCurrentConfig(options)
self.assertEquals(1, len(obj.dependencies))
sol = obj.dependencies[0]
sol._condition = 'some_condition'
sol.ParseDepsFile()
self.assertEquals(1, len(sol.dependencies))
dep = sol.dependencies[0]
self.assertIsInstance(dep, gclient.CipdDependency)
self.assertEquals(
'https://chrome-infra-packages.appspot.com/lemur@version:1234',
dep.url)
def testDepsFromNotAllowedHostsUnspecified(self):
"""Verifies gclient works fine with DEPS without allowed_hosts."""
write(
@ -991,7 +1033,7 @@ class GclientTest(trial_dir.TestCase):
self._get_processed()
def testCreatesCipdDependencies(self):
"""Verifies something."""
"""Verifies that CIPD deps are created correctly."""
write(
'.gclient',
'solutions = [\n'
@ -1030,6 +1072,46 @@ class GclientTest(trial_dir.TestCase):
'https://chrome-infra-packages.appspot.com/lemur@version:1234',
dep.url)
def testIgnoresCipdDependenciesWhenFlagIsSet(self):
"""Verifies that CIPD deps are ignored if --ignore-dep-type cipd is set."""
write(
'.gclient',
'solutions = [\n'
' { "name": "foo", "url": "https://example.com/foo",\n'
' "deps_file" : ".DEPS.git",\n'
' },\n'
']')
write(
os.path.join('foo', 'DEPS'),
'vars = {\n'
' "lemur_version": "version:1234",\n'
'}\n'
'deps = {\n'
' "bar": "/bar",\n'
' "baz": {\n'
' "packages": [{\n'
' "package": "lemur",\n'
' "version": Var("lemur_version"),\n'
' }],\n'
' "dep_type": "cipd",\n'
' }\n'
'}')
options, _ = gclient.OptionParser().parse_args([])
options.ignore_dep_type = 'cipd'
options.validate_syntax = True
obj = gclient.GClient.LoadCurrentConfig(options)
self.assertEquals(1, len(obj.dependencies))
sol = obj.dependencies[0]
sol._condition = 'some_condition'
sol.ParseDepsFile()
self.assertEquals(1, len(sol.dependencies))
dep = sol.dependencies[0]
self.assertIsInstance(dep, gclient.GitDependency)
self.assertEquals('https://example.com/bar', dep.url)
def testSameDirAllowMultipleCipdDeps(self):
"""Verifies gclient allow multiple cipd deps under same directory."""
parser = gclient.OptionParser()

Loading…
Cancel
Save