output actual CIPD package URL instead of 'None' when calling revinfo -a

Note: we are only evaluating cipd variables in the URL not the package string on the left hand side, as to not break any existing expected behaviour.

Bug:b/279097790
Change-Id: I0b6008254bd387584b9c0ee083c79bf5dc77fbc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4536475
Commit-Queue: Dan Le Febvre <dlf@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
changes/75/4536475/10
Dan Le Febvre 2 years ago committed by LUCI CQ
parent b6cb9e0b9a
commit b0e8e7adbc

@ -538,6 +538,11 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
return
url = None
scm = self.CreateSCM()
if scm.name == 'cipd':
revision = scm.revinfo(None, None, None)
package = self.GetExpandedPackageName()
url = '%s/p/%s/+/%s' % (scm.GetActualRemoteURL(None), package, revision)
if os.path.isdir(scm.checkout_path):
revision = scm.revinfo(None, None, None)
url = '%s@%s' % (gclient_utils.SplitUrlRevision(self.url)[0], revision)
@ -2277,6 +2282,13 @@ class CipdDependency(Dependency):
"""Always 'cipd'."""
return 'cipd'
def GetExpandedPackageName(self):
"""Return the CIPD package name with the variables evaluated."""
package = self._cipd_root.expand_package_name(self._package_name)
if package:
return package
return self._package_name
#override
def CreateSCM(self, out_cb=None):
"""Create a Wrapper instance suitable for handling this CIPD dependency."""

@ -1,4 +1,4 @@
echo off
@echo off
:: Copyright (c) 2018 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.

@ -212,7 +212,7 @@ class FakeReposBase(object):
class FakeRepos(FakeReposBase):
"""Implements populateGit()."""
NB_GIT_REPOS = 17
NB_GIT_REPOS = 18
def populateGit(self):
# Testing:
@ -732,6 +732,30 @@ hooks = [{
'origin': 'git/repo_17@2\n'
})
self._commit_git(
'repo_18', {
'DEPS':
textwrap.dedent("""\
deps = {
'src/cipd_dep': {
'packages': [
{
'package': 'package0',
'version': 'package0-fake-tag:1.0',
},
{
'package': 'package0/${{platform}}',
'version': 'package0/${{platform}}-fake-tag:1.0',
},
],
'dep_type': 'cipd',
},
}"""),
'origin':
'git/repo_18@2\n'
})
class FakeRepoSkiaDEPS(FakeReposBase):
"""Simulates the Skia DEPS transition in Chrome."""

@ -17,6 +17,8 @@ import gclient_smoketest_base
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CHROME_INFRA_URL = "https://chrome-infra-packages.appspot.com"
class GClientSmokeCipd(gclient_smoketest_base.GClientSmokeBase):
def setUp(self):
@ -132,6 +134,42 @@ class GClientSmokeCipd(gclient_smoketest_base.GClientSmokeBase):
})
self.assertTree(tree)
def testRevInfo(self):
self.gclient(['config', self.git_base + 'repo_18', '--name', 'src'])
self.gclient(['sync'])
results = self.gclient(['revinfo'])
out = ('src: %(base)srepo_18\n'
'src/cipd_dep:package0: %(instance_url1)s\n'
'src/cipd_dep:package0/${platform}: %(instance_url2)s\n' % {
'base':
self.git_base,
'instance_url1':
CHROME_INFRA_URL + '/package0@package0-fake-tag:1.0',
'instance_url2':
CHROME_INFRA_URL +
'/package0/${platform}@package0/${platform}-fake-tag:1.0',
})
self.check((out, '', 0), results)
def testRevInfoActual(self):
self.gclient(['config', self.git_base + 'repo_18', '--name', 'src'])
self.gclient(['sync'])
results = self.gclient(['revinfo', '--actual'])
out = ('src: %(base)srepo_18@%(hash1)s\n'
'src/cipd_dep:package0: %(instance_url1)s\n'
'src/cipd_dep:package0/${platform}: %(instance_url2)s\n' % {
'base':
self.git_base,
'hash1':
self.githash('repo_18', 1),
'instance_url1':
CHROME_INFRA_URL + '/p/package0/+/package0-fake-instance-id',
'instance_url2':
CHROME_INFRA_URL + '/p/package0/platform-expanded-test-only' +
'/+/package0/${platform}-fake-instance-id',
})
self.check((out, '', 0), results)
if __name__ == '__main__':
if '-v' in sys.argv:

Loading…
Cancel
Save