summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--git_command.py14
-rwxr-xr-xrepo19
2 files changed, 19 insertions, 14 deletions
diff --git a/git_command.py b/git_command.py
index 89b681e1..354fc715 100644
--- a/git_command.py
+++ b/git_command.py
@@ -21,6 +21,7 @@ import tempfile
21from signal import SIGTERM 21from signal import SIGTERM
22from error import GitError 22from error import GitError
23from trace import REPO_TRACE, IsTrace, Trace 23from trace import REPO_TRACE, IsTrace, Trace
24from wrapper import Wrapper
24 25
25GIT = 'git' 26GIT = 'git'
26MIN_GIT_VERSION = (1, 5, 4) 27MIN_GIT_VERSION = (1, 5, 4)
@@ -84,19 +85,10 @@ class _GitCall(object):
84 85
85 def version_tuple(self): 86 def version_tuple(self):
86 global _git_version 87 global _git_version
87
88 if _git_version is None: 88 if _git_version is None:
89 ver_str = git.version().decode('utf-8') 89 ver_str = git.version().decode('utf-8')
90 if ver_str.startswith('git version '): 90 _git_version = Wrapper().ParseGitVersion(ver_str)
91 num_ver_str = ver_str[len('git version '):].strip().split('-')[0] 91 if _git_version is None:
92 to_tuple = []
93 for num_str in num_ver_str.split('.')[:3]:
94 if num_str.isdigit():
95 to_tuple.append(int(num_str))
96 else:
97 to_tuple.append(0)
98 _git_version = tuple(to_tuple)
99 else:
100 print('fatal: "%s" unsupported' % ver_str, file=sys.stderr) 92 print('fatal: "%s" unsupported' % ver_str, file=sys.stderr)
101 sys.exit(1) 93 sys.exit(1)
102 return _git_version 94 return _git_version
diff --git a/repo b/repo
index 56d784fb..1587fef4 100755
--- a/repo
+++ b/repo
@@ -278,6 +278,20 @@ def _Init(args):
278 raise 278 raise
279 279
280 280
281def ParseGitVersion(ver_str):
282 if not ver_str.startswith('git version '):
283 return None
284
285 num_ver_str = ver_str[len('git version '):].strip().split('-')[0]
286 to_tuple = []
287 for num_str in num_ver_str.split('.')[:3]:
288 if num_str.isdigit():
289 to_tuple.append(int(num_str))
290 else:
291 to_tuple.append(0)
292 return tuple(to_tuple)
293
294
281def _CheckGitVersion(): 295def _CheckGitVersion():
282 cmd = [GIT, '--version'] 296 cmd = [GIT, '--version']
283 try: 297 try:
@@ -295,12 +309,11 @@ def _CheckGitVersion():
295 proc.stdout.close() 309 proc.stdout.close()
296 proc.wait() 310 proc.wait()
297 311
298 if not ver_str.startswith('git version '): 312 ver_act = ParseGitVersion(ver_str)
313 if ver_act is None:
299 _print('error: "%s" unsupported' % ver_str, file=sys.stderr) 314 _print('error: "%s" unsupported' % ver_str, file=sys.stderr)
300 raise CloneFailure() 315 raise CloneFailure()
301 316
302 ver_str = ver_str[len('git version '):].strip()
303 ver_act = tuple(map(int, ver_str.split('.')[0:3]))
304 if ver_act < MIN_GIT_VERSION: 317 if ver_act < MIN_GIT_VERSION:
305 need = '.'.join(map(str, MIN_GIT_VERSION)) 318 need = '.'.join(map(str, MIN_GIT_VERSION))
306 _print('fatal: git %s or later required' % need, file=sys.stderr) 319 _print('fatal: git %s or later required' % need, file=sys.stderr)