diff options
-rwxr-xr-x | repo | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -383,7 +383,11 @@ def _Init(args, gitc_init=False): | |||
383 | GitVersion = collections.namedtuple( | 383 | GitVersion = collections.namedtuple( |
384 | 'GitVersion', ('major', 'minor', 'micro', 'full')) | 384 | 'GitVersion', ('major', 'minor', 'micro', 'full')) |
385 | 385 | ||
386 | def ParseGitVersion(ver_str): | 386 | def ParseGitVersion(ver_str=None): |
387 | if ver_str is None: | ||
388 | # Load the version ourselves. | ||
389 | ver_str = _GetGitVersion() | ||
390 | |||
387 | if not ver_str.startswith('git version '): | 391 | if not ver_str.startswith('git version '): |
388 | return None | 392 | return None |
389 | 393 | ||
@@ -399,7 +403,7 @@ def ParseGitVersion(ver_str): | |||
399 | return GitVersion(*to_tuple) | 403 | return GitVersion(*to_tuple) |
400 | 404 | ||
401 | 405 | ||
402 | def _CheckGitVersion(): | 406 | def _GetGitVersion(): |
403 | cmd = [GIT, '--version'] | 407 | cmd = [GIT, '--version'] |
404 | try: | 408 | try: |
405 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) | 409 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
@@ -410,13 +414,20 @@ def _CheckGitVersion(): | |||
410 | print(file=sys.stderr) | 414 | print(file=sys.stderr) |
411 | print('Please make sure %s is installed and in your path.' % GIT, | 415 | print('Please make sure %s is installed and in your path.' % GIT, |
412 | file=sys.stderr) | 416 | file=sys.stderr) |
413 | raise CloneFailure() | 417 | raise |
414 | 418 | ||
415 | ver_str = proc.stdout.read().strip() | 419 | ver_str = proc.stdout.read().strip() |
416 | proc.stdout.close() | 420 | proc.stdout.close() |
417 | proc.wait() | 421 | proc.wait() |
422 | return ver_str.decode('utf-8') | ||
423 | |||
424 | |||
425 | def _CheckGitVersion(): | ||
426 | try: | ||
427 | ver_act = ParseGitVersion() | ||
428 | except OSError: | ||
429 | raise CloneFailure() | ||
418 | 430 | ||
419 | ver_act = ParseGitVersion(ver_str) | ||
420 | if ver_act is None: | 431 | if ver_act is None: |
421 | print('error: "%s" unsupported' % ver_str, file=sys.stderr) | 432 | print('error: "%s" unsupported' % ver_str, file=sys.stderr) |
422 | raise CloneFailure() | 433 | raise CloneFailure() |