$this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$e->getMessage().')</error>');
}
} else {
// clean up directory and do a fresh clone into it
$fs->removeDirectory($this->repoDir);
$repoDir = $this->repoDir;
$commandCallable = function ($url) use ($repoDir) {
private function isAuthenticationFailure($url, &$match)
{
if (!preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match)) {
@ -277,16 +307,18 @@ class Git
/**
* Retrieves the current git version.
*
* @return string
* The git version number.
* @return string|null The git version number.
*/
public function getVersion() {
public function getVersion()
{
if (isset(self::$version)) {
return self::$version;
}
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()));
return;
}
if (preg_match('/^git version (.*)/', $output, $matches) !== 1) {
throw new \RuntimeException('git --version output seems to have changed, expected "git version x.y.z".');
if (preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {