From 75b88a13fea24de7fea0d2a35691d3087b50a040 Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Sat, 18 Jun 2016 17:43:25 -0500 Subject: [PATCH] Use regex to capture git version. --- src/Composer/Util/Git.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 19e0a8e46..d1fb18a09 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -282,9 +282,9 @@ class Git if (0 !== $this->process->execute('git --version', $output)) { throw new \RuntimeException(self::sanitizeUrl('Failed retrieve git version, git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput())); } - if (strpos($output, 'git version ') === FALSE) { + if (preg_match('/^git version (.*)/', $output, $matches) !== 1) { throw new \RuntimeException('git --version output seems to have changed, expected "git version x.y.z".'); } - return substr($output, 12); + return $matches[1]; } }