Commit 6f83031f authored by Shenghua Zhang's avatar Shenghua Zhang Committed by Commit Bot

[cipd] Support cipd dependencies hooked under same directory

When hooks multiple cipd packages under same directory, gclient would
pop up error that same directory name appears multiple times in deps
section. This CL overrides verify_validity for CipdDependency to
support multiple packages hooked in same directory.

Bug:812386
Change-Id: Ia4f1fe0e3c8481c9b06c1d22b6e98d98e1e4c309
Reviewed-on: https://chromium-review.googlesource.com/920686
Commit-Queue: Shenghua Zhang <shenghuazhang@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent f438ff74
......@@ -1878,7 +1878,7 @@ class CipdDependency(Dependency):
url = urlparse.urljoin(
cipd_root.service_url, '%s@%s' % (package, version))
super(CipdDependency, self).__init__(
parent, name, url, url, None, None, custom_vars,
parent, name + ':' + package, url, url, None, None, custom_vars,
None, None, should_process, relative, condition, condition_value)
if relative:
# TODO(jbudorick): Implement relative if necessary.
......@@ -1887,7 +1887,7 @@ class CipdDependency(Dependency):
self._cipd_root = cipd_root
self._cipd_subdir = os.path.relpath(
os.path.join(self.root.root_dir, self.name), cipd_root.root_dir)
os.path.join(self.root.root_dir, name), cipd_root.root_dir)
self._cipd_package = self._cipd_root.add_package(
self._cipd_subdir, package, version)
......@@ -1895,6 +1895,12 @@ class CipdDependency(Dependency):
"""CIPD dependencies are not currently allowed to have nested deps."""
self.add_dependencies_and_close([], [])
#override
def verify_validity(self):
"""CIPD dependencies allow duplicate name for packages in same directory."""
logging.info('Dependency(%s).verify_validity()' % self.name)
return True
#override
def GetScmName(self, url):
"""Always 'cipd'."""
......
......@@ -1138,8 +1138,8 @@ class GClientSmokeGIT(GClientSmokeBase):
' "url": "git://127.0.0.1:20000/git/repo_14",',
' },',
'',
' # src -> src/cipd_dep',
' "src/cipd_dep": {',
' # src -> src/cipd_dep:package0',
' "src/cipd_dep:package0": {',
' "packages": [',
' {',
' "package": "package0",',
......
......@@ -19,6 +19,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import gclient
import gclient_utils
import gclient_scm
from testing_support import trial_dir
......@@ -1154,6 +1155,39 @@ class GclientTest(trial_dir.TestCase):
finally:
self._get_processed()
def testSameDirAllowMultipleCipdDeps(self):
"""Verifies gclient allow multiple cipd deps under same directory."""
parser = gclient.OptionParser()
options, _ = parser.parse_args([])
obj = gclient.GClient('foo', options)
cipd_root = gclient_scm.CipdRoot(
os.path.join(self.root_dir, 'dir1'), 'https://example.com')
obj.add_dependencies_and_close(
[
gclient.Dependency(
obj, 'foo', 'raw_url', 'url', None, None, None, None, 'DEPS', True,
False, None, True),
],
[])
obj.dependencies[0].add_dependencies_and_close(
[
gclient.CipdDependency(obj.dependencies[0], 'foo',
{'package': 'foo_package',
'version': 'foo_version'},
cipd_root, None, True, False,
'fake_condition', True),
gclient.CipdDependency(obj.dependencies[0], 'foo',
{'package': 'bar_package',
'version': 'bar_version'},
cipd_root, None, True, False,
'fake_condition', True),
],
[])
dep0 = obj.dependencies[0].dependencies[0]
dep1 = obj.dependencies[0].dependencies[1]
self.assertEquals('https://example.com/foo_package@foo_version', dep0.url)
self.assertEquals('https://example.com/bar_package@bar_version', dep1.url)
if __name__ == '__main__':
sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
......
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