summaryrefslogtreecommitdiffstats
path: root/git_command.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_command.py')
-rw-r--r--git_command.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/git_command.py b/git_command.py
index 7ff1abac..d56ad0a8 100644
--- a/git_command.py
+++ b/git_command.py
@@ -68,6 +68,30 @@ class _GitCall(object):
68 return fun 68 return fun
69git = _GitCall() 69git = _GitCall()
70 70
71_git_version = None
72
73def git_require(min_version, fail=False):
74 global _git_version
75
76 if _git_version is None:
77 ver_str = git.version()
78 if ver_str.startswith('git version '):
79 _git_version = tuple(
80 map(lambda x: int(x),
81 ver_str[len('git version '):].strip().split('.')[0:3]
82 ))
83 else:
84 print >>sys.stderr, 'fatal: "%s" unsupported' % ver_str
85 sys.exit(1)
86
87 if min_version <= _git_version:
88 return True
89 if fail:
90 need = '.'.join(map(lambda x: str(x), min_version))
91 print >>sys.stderr, 'fatal: git %s or later required' % need
92 sys.exit(1)
93 return False
94
71class GitCommand(object): 95class GitCommand(object):
72 def __init__(self, 96 def __init__(self,
73 project, 97 project,