Patchwork [2/2] scripts/buildhistory-diff: add GitPython version check

login
register
mail settings
Submitter Paul Eggleton
Date May 28, 2012, 12:57 p.m.
Message ID <c8a933748f02987afb7d68f38ff4c48ed6c9ae48.1338209763.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/28853/
State Accepted
Commit 2f0f5a895504924b5a21699854678e9bc25b447c
Headers show

Comments

Paul Eggleton - May 28, 2012, 12:57 p.m.
Display an error if the user does not have at least version 0.3.1 of
GitPython installed.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 scripts/buildhistory-diff |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index 9936a4b..3f27eab 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -7,16 +7,20 @@ 
 
 import sys
 import os
+from distutils.version import LooseVersion
 
 # Ensure PythonGit is installed (buildhistory_analysis needs it)
 try:
     import git
 except ImportError:
-    print("Please install PythonGit 0.3.1 or later in order to use this script")
+    print("Please install GitPython (python-git) 0.3.1 or later in order to use this script")
     sys.exit(1)
 
-
 def main():
+    if LooseVersion(git.__version__) < '0.3.1':
+        print("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script")
+        sys.exit(1)
+
     if (len(sys.argv) < 3):
         print("Report significant differences in the buildhistory repository")
         print("Syntax: %s <buildhistory-path> <since-revision> [to-revision]" % os.path.basename(sys.argv[0]))