mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
main: rework launcher version checking
The code has an ad-hoc check in that it requires the launcher major version to not be less than the source code version. We don't really care about that requirement, and it doesn't fit with our other version checks. Rework it so we explicitly declare the min launcher version that is supported. We'll start with requiring repo launcher 1.15 which was released back in 2012. Hopefully no one has anything older than that, although it's not clear we work with even newer versions than that :). But let's be a little conservative with the first update to this logic. Bug: https://crbug.com/gerrit/10418 Change-Id: I611d70c60324d313c76874e978b8499a491a5d00 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254278 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
ae62541005
commit
3285e4b436
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user