Fix error reporting for missing git process
parent
720b00b561
commit
6f8031ac90
|
@ -95,17 +95,12 @@ class GitDownloader extends VcsDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
// failed to checkout, first check git accessibility
|
// failed to checkout, first check git accessibility
|
||||||
$output = $this->process->getErrorOutput();
|
$this->throwException('Failed to clone ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . $this->process->getErrorOutput(), $url);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = call_user_func($commandCallable, $url);
|
$command = call_user_func($commandCallable, $url);
|
||||||
if (0 !== $this->process->execute($command, $handler)) {
|
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)
|
protected function setPushUrl(PackageInterface $package, $path)
|
||||||
{
|
{
|
||||||
// set push url for github projects
|
// set push url for github projects
|
||||||
|
|
|
@ -55,11 +55,11 @@ class GitDriver extends VcsDriver
|
||||||
if (0 !== $this->process->execute($command, $output)) {
|
if (0 !== $this->process->execute($command, $output)) {
|
||||||
$output = $this->process->getErrorOutput();
|
$output = $this->process->getErrorOutput();
|
||||||
|
|
||||||
if (127 === $this->process->execute('git --version', $handler)) {
|
if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
|
||||||
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());
|
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')
|
->method('getSourceUrl')
|
||||||
->will($this->returnValue('https://example.com/composer/composer'));
|
->will($this->returnValue('https://example.com/composer/composer'));
|
||||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||||
$processExecutor->expects($this->once())
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedGitCommand))
|
||||||
->will($this->returnValue(1));
|
->will($this->returnValue(1));
|
||||||
|
|
Loading…
Reference in New Issue