From: Christian Weiske Date: Thu, 26 Apr 2012 04:43:38 +0000 (+0200) Subject: check git version in setupcheck X-Git-Tag: v0.2.0~41 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/d9d9656d3e346d17607b328e37b5bf4daad7bed5 check git version in setupcheck --- diff --git a/src/phorkie/SetupCheck.php b/src/phorkie/SetupCheck.php index 959ff42..2c0dd80 100644 --- a/src/phorkie/SetupCheck.php +++ b/src/phorkie/SetupCheck.php @@ -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);