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
diff --git a/git_command.py b/git_command.py
index 51f5e3c..58fc751 100644
--- a/git_command.py
+++ b/git_command.py
@@ -88,10 +88,14 @@
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)