[PATCH 03/14] [git] Make git version checks more readable



Wrap the generic version checker into a git specific one and use it.

Signed-off-by: Dirk Wallenstein <halsmit t-online de>
---
 jhbuild/versioncontrol/git.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/jhbuild/versioncontrol/git.py b/jhbuild/versioncontrol/git.py
index 0145a66..abf9b2c 100644
--- a/jhbuild/versioncontrol/git.py
+++ b/jhbuild/versioncontrol/git.py
@@ -168,6 +168,10 @@ class GitBranch(Branch):
         return self._execute_git_predicate(
                 ['git', 'rev-parse', '--is-inside-work-tree'])
 
+    def _check_version_git(self, version_spec):
+        return check_version(['git', '--version'], r'git version ([\d.]+)',
+                version_spec, extra_env=get_git_extra_env())
+
     def _get_current_branch(self):
         """Returns either a branchname or None if head is detached"""
         if not self._is_inside_work_tree():
@@ -284,9 +288,7 @@ class GitBranch(Branch):
         if update_mirror:
             self.update_dvcs_mirror(buildscript)
 
-        if check_version(['git', '--version'],
-                     r'git version ([\d.]+)', '1.7.0',
-                     extra_env=get_git_extra_env()):
+        if self._check_version_git('1.7.0'):
             git_diff_submodule = ['--submodule']
         else:
             git_diff_submodule = []
@@ -332,9 +334,7 @@ class GitBranch(Branch):
 
         if stashed:
             # git stash pop was introduced in 1.5.5, 
-            if check_version(['git', '--version'],
-                         r'git version ([\d.]+)', '1.5.5',
-                         extra_env=get_git_extra_env()):
+            if self._check_version_git('1.5.5'):
                 buildscript.execute(['git', 'stash', 'pop'], **git_extra_args)
             else:
                 buildscript.execute(['git', 'stash', 'apply', 'jhbuild-stash'],
-- 
1.7.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]