Merge pull request #712 from hason/githuberror
Imporoved exception message for GitDownloader (various protocols for git...pull/710/merge
commit
3ff4026a30
|
@ -92,18 +92,20 @@ class GitDownloader extends VcsDownloader
|
||||||
// github, autoswitch protocols
|
// github, autoswitch protocols
|
||||||
if (preg_match('{^(?:https?|git)(://github.com/.*)}', $url, $match)) {
|
if (preg_match('{^(?:https?|git)(://github.com/.*)}', $url, $match)) {
|
||||||
$protocols = array('git', 'https', 'http');
|
$protocols = array('git', 'https', 'http');
|
||||||
|
$messages = array();
|
||||||
foreach ($protocols as $protocol) {
|
foreach ($protocols as $protocol) {
|
||||||
$url = $protocol . $match[1];
|
$url = $protocol . $match[1];
|
||||||
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $handler)) {
|
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $handler)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$messages[] = '- ' . $url . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
|
||||||
if (null !== $path) {
|
if (null !== $path) {
|
||||||
$this->filesystem->removeDirectory($path);
|
$this->filesystem->removeDirectory($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// failed to checkout, first check git accessibility
|
// 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);
|
$this->throwException('Failed to clone ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = call_user_func($commandCallable, $url);
|
$command = call_user_func($commandCallable, $url);
|
||||||
|
|
|
@ -78,19 +78,19 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue(1));
|
->will($this->returnValue(1));
|
||||||
|
|
||||||
$expectedGitCommand = $this->getCmd("git clone 'https://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'https://github.com/composer/composer'");
|
$expectedGitCommand = $this->getCmd("git clone 'https://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'https://github.com/composer/composer'");
|
||||||
$processExecutor->expects($this->at(1))
|
$processExecutor->expects($this->at(2))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedGitCommand))
|
||||||
->will($this->returnValue(1));
|
->will($this->returnValue(1));
|
||||||
|
|
||||||
$expectedGitCommand = $this->getCmd("git clone 'http://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'http://github.com/composer/composer'");
|
$expectedGitCommand = $this->getCmd("git clone 'http://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git checkout 'ref' && git reset --hard 'ref' && git remote add composer 'http://github.com/composer/composer'");
|
||||||
$processExecutor->expects($this->at(2))
|
$processExecutor->expects($this->at(4))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedGitCommand))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$expectedGitCommand = $this->getCmd("git remote set-url --push origin 'git@github.com:composer/composer.git'");
|
$expectedGitCommand = $this->getCmd("git remote set-url --push origin 'git@github.com:composer/composer.git'");
|
||||||
$processExecutor->expects($this->at(3))
|
$processExecutor->expects($this->at(5))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo('composerPath'))
|
->with($this->equalTo($expectedGitCommand), $this->equalTo(null), $this->equalTo('composerPath'))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
Loading…
Reference in New Issue