Fix error reporting for missing git process

main
Jordi Boggiano 12 years ago
parent 720b00b561
commit 6f8031ac90

@ -93,19 +93,14 @@ class GitDownloader extends VcsDownloader
$this->filesystem->removeDirectory($path);
}
}
// failed to checkout, first check git accessibility
$output = $this->process->getErrorOutput();
if (127 === $this->process->execute('git --version', $handler)) {
throw new \RuntimeException('Failed to checkout ' . $url . ' via git, it isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput());
}
throw new \RuntimeException('Failed to checkout ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $output);
// failed to checkout, first check git accessibility
$this->throwException('Failed to clone ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $this->process->getErrorOutput(), $url);
}
$command = call_user_func($commandCallable, $url);
if (0 !== $this->process->execute($command, $handler)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
$this->throwException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput(), $url);
}
}
@ -119,6 +114,15 @@ class GitDownloader extends VcsDownloader
}
}
protected function throwException($message, $url)
{
if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
throw new \RuntimeException('Failed to clone '.$url.', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
}
throw new \RuntimeException($message);
}
protected function setPushUrl(PackageInterface $package, $path)
{
// set push url for github projects

@ -54,12 +54,12 @@ class GitDriver extends VcsDriver
$command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir));
if (0 !== $this->process->execute($command, $output)) {
$output = $this->process->getErrorOutput();
if (127 === $this->process->execute('git --version', $handler)) {
throw new \RuntimeException('Failed to clone '.$this->url.', git isn\'t accessible through the console, please check your installation and your PATH env.' . "\n\n" . $this->process->getErrorOutput());
if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
throw new \RuntimeException('Failed to clone '.$this->url.', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
}
throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it ('.$output.')');
throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it' . "\n\n" .$output);
}
}
}

@ -113,7 +113,7 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
->method('getSourceUrl')
->will($this->returnValue('https://example.com/composer/composer'));
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
$processExecutor->expects($this->once())
$processExecutor->expects($this->at(0))
->method('execute')
->with($this->equalTo($expectedGitCommand))
->will($this->returnValue(1));

Loading…
Cancel
Save