From 1c5da49e6c0c2dd6a5f0ba6e5b57ecb783c27eea Mon Sep 17 00:00:00 2001 From: Conley Owens Date: Thu, 30 Jan 2014 13:09:08 -0800 Subject: [PATCH] Handle release candidates in git version parsing Right now repo chokes on git versions like "1.9.rc1". This change treats 'rc*' as a '0'. Change-Id: I612b7b431675ba7415bf70640a673e48dbb00a90 --- git_command.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/git_command.py b/git_command.py index 51f5e3c0..58fc7518 100644 --- a/git_command.py +++ b/git_command.py @@ -88,10 +88,14 @@ class _GitCall(object): if _git_version is None: ver_str = git.version().decode('utf-8') if ver_str.startswith('git version '): - _git_version = tuple( - map(int, - ver_str[len('git version '):].strip().split('-')[0].split('.')[0:3] - )) + num_ver_str = ver_str[len('git version '):].strip() + to_tuple = [] + for num_str in num_ver_str.split('.')[:3]: + if num_str.isdigit(): + to_tuple.append(int(num_str)) + else: + to_tuple.append(0) + _git_version = tuple(to_tuple) else: print('fatal: "%s" unsupported' % ver_str, file=sys.stderr) sys.exit(1)