check git version in setupcheck
authorChristian Weiske <cweiske@cweiske.de>
Thu, 26 Apr 2012 04:43:38 +0000 (06:43 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 26 Apr 2012 04:43:38 +0000 (06:43 +0200)
src/phorkie/SetupCheck.php

index 959ff428c10e9b3078833cb610c949e497120aaf..2c0dd801f0588c0a0deca5e2111c2013c67ba4ee 100644 (file)
@@ -26,6 +26,7 @@ class SetupCheck
         $sc = new self();
         $sc->checkDeps();
         $sc->checkDirs();
+        $sc->checkGit();
     }
 
     public function checkDeps()
@@ -49,6 +50,22 @@ class SetupCheck
         }
     }
 
+    public function checkGit()
+    {
+        $line = exec('git --version', $lines, $retval);
+        if ($retval !== 0) {
+            $this->fail('Running git executable failed.');
+        }
+        if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
+            $this->fail('git version output format unexpected: ' . $line);
+        }
+        if (version_compare($matches[1], '1.7.5') < 0) {
+            $this->fail(
+                'git version needs to be at least 1.7.5, got: ' . $matches[1]
+            );
+        }
+    }
+
     public function fail($msg)
     {
         throw new Exception($msg);