Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: scm.py

Issue 878001: Extract git version check code from gclient_scm.py into scm.py where it belongs. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index 1dce4bd7ccd9d35dd6e3a8b09788c70c03a8036d..b4553765ae1fa248c85ffe56836e6e8fa336a7cb 100644
--- a/scm.py
+++ b/scm.py
@@ -270,6 +270,24 @@ class GIT(object):
root = GIT.Capture(['rev-parse', '--show-cdup'], path)[0].strip()
return os.path.abspath(os.path.join(path, root))
+ @staticmethod
+ def AssertVersion(min_version):
+ """Asserts git's version is at least min_version."""
+ def only_int(val):
+ if val.isdigit():
+ return int(val)
+ else:
+ return 0
+ current_version = GIT.Capture(['--version'])[0].split()[-1]
+ current_version_list = map(only_int, current_version.split('.'))
+ for min_ver in map(int, min_version.split('.')):
+ ver = current_version_list.pop(0)
+ if ver < min_ver:
+ return (False, current_version)
+ elif ver > min_ver:
+ return (True, current_version)
+ return (True, current_version)
+
class SVN(object):
COMMAND = "svn"
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698