mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
manifest_xml: allow src=. with symlinks
Some Android/Nest manifests are using <linkfile> with src="." to create stable paths to specific projects. Allow that specific use case as it seems reasonable to support. Bug: https://crbug.com/gerrit/11218 Change-Id: I5eadec257cd58ba0f8687c590ddc250a7a414a85 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254276 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
83a3227b62
commit
ae62541005
@ -985,11 +985,13 @@ class XmlManifest(object):
|
|||||||
# Assume paths might be used on case-insensitive filesystems.
|
# Assume paths might be used on case-insensitive filesystems.
|
||||||
path = path.lower()
|
path = path.lower()
|
||||||
|
|
||||||
# We don't really need to reject '.' here, but there shouldn't really be a
|
# Some people use src="." to create stable links to projects. Lets allow
|
||||||
# need to ever use it, so no need to accept it either.
|
# that but reject all other uses of "." to keep things simple.
|
||||||
for part in set(path.split(os.path.sep)):
|
parts = path.split(os.path.sep)
|
||||||
if part in {'.', '..', '.git'} or part.startswith('.repo'):
|
if parts != ['.']:
|
||||||
return 'bad component: %s' % (part,)
|
for part in set(parts):
|
||||||
|
if part in {'.', '..', '.git'} or part.startswith('.repo'):
|
||||||
|
return 'bad component: %s' % (part,)
|
||||||
|
|
||||||
if not symlink and path.endswith(os.path.sep):
|
if not symlink and path.endswith(os.path.sep):
|
||||||
return 'dirs not allowed'
|
return 'dirs not allowed'
|
||||||
|
@ -49,6 +49,8 @@ class ManifestValidateFilePaths(unittest.TestCase):
|
|||||||
# We allow symlinks to end in a slash since we allow them to point to dirs
|
# We allow symlinks to end in a slash since we allow them to point to dirs
|
||||||
# in general. Technically the slash isn't necessary.
|
# in general. Technically the slash isn't necessary.
|
||||||
check('foo/', 'bar')
|
check('foo/', 'bar')
|
||||||
|
# We allow a single '.' to get a reference to the project itself.
|
||||||
|
check('.', 'bar')
|
||||||
|
|
||||||
def test_bad_paths(self):
|
def test_bad_paths(self):
|
||||||
"""Make sure bad paths (src & dest) are rejected."""
|
"""Make sure bad paths (src & dest) are rejected."""
|
||||||
|
Loading…
Reference in New Issue
Block a user