mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-30 20:17:08 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
3285e4b436 | |||
ae62541005 |
32
main.py
32
main.py
@ -255,27 +255,41 @@ class _Repo(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _CheckWrapperVersion(ver, repo_path):
|
def _CheckWrapperVersion(ver_str, repo_path):
|
||||||
|
"""Verify the repo launcher is new enough for this checkout.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
ver_str: The version string passed from the repo launcher when it ran us.
|
||||||
|
repo_path: The path to the repo launcher that loaded us.
|
||||||
|
"""
|
||||||
|
# Refuse to work with really old wrapper versions. We don't test these,
|
||||||
|
# so might as well require a somewhat recent sane version.
|
||||||
|
# v1.15 of the repo launcher was released in ~Mar 2012.
|
||||||
|
MIN_REPO_VERSION = (1, 15)
|
||||||
|
min_str = '.'.join(str(x) for x in MIN_REPO_VERSION)
|
||||||
|
|
||||||
if not repo_path:
|
if not repo_path:
|
||||||
repo_path = '~/bin/repo'
|
repo_path = '~/bin/repo'
|
||||||
|
|
||||||
if not ver:
|
if not ver_str:
|
||||||
print('no --wrapper-version argument', file=sys.stderr)
|
print('no --wrapper-version argument', file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Pull out the version of the repo launcher we know about to compare.
|
||||||
exp = Wrapper().VERSION
|
exp = Wrapper().VERSION
|
||||||
ver = tuple(map(int, ver.split('.')))
|
ver = tuple(map(int, ver_str.split('.')))
|
||||||
if len(ver) == 1:
|
|
||||||
ver = (0, ver[0])
|
|
||||||
|
|
||||||
exp_str = '.'.join(map(str, exp))
|
exp_str = '.'.join(map(str, exp))
|
||||||
if exp[0] > ver[0] or ver < (0, 4):
|
if ver < MIN_REPO_VERSION:
|
||||||
print("""
|
print("""
|
||||||
!!! A new repo command (%5s) is available. !!!
|
repo: error:
|
||||||
!!! You must upgrade before you can continue: !!!
|
!!! Your version of repo %s is too old.
|
||||||
|
!!! We need at least version %s.
|
||||||
|
!!! A new repo command (%s) is available.
|
||||||
|
!!! You must upgrade before you can continue:
|
||||||
|
|
||||||
cp %s %s
|
cp %s %s
|
||||||
""" % (exp_str, WrapperPath(), repo_path), file=sys.stderr)
|
""" % (ver_str, min_str, exp_str, WrapperPath(), repo_path), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if exp > ver:
|
if exp > ver:
|
||||||
|
@ -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."""
|
||||||
|
Reference in New Issue
Block a user