@ -77,8 +77,8 @@ class GitDownloader extends VcsDownloader
return;
}
$command = sprintf('cd %s &&git status --porcelain --untracked-files=no', escapeshellarg($path));
if (0 !== $this->process->execute($command, $output)) {
$command = 'git status --porcelain --untracked-files=no';
if (0 !== $this->process->execute($command, $output, $path)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
}
@ -264,11 +264,17 @@ class GitDownloader extends VcsDownloader
*
* @param callable $commandCallable A callable building the command for the given url
* @param string $url
* @param string $path The directory to remove for each attempt (null if not needed)
* @param string $cwd
* @param bool $initialClone If true, the directory if cleared between every attempt
* @throws \RuntimeException
*/
protected function runCommand($commandCallable, $url, $path = null)
protected function runCommand($commandCallable, $url, $cwd, $initialClone = false)
{
if ($initialClone) {
$origCwd = $cwd;
$cwd = dirname($cwd);
}
if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
throw new \InvalidArgumentException('The source URL '.$url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
}
@ -282,12 +288,12 @@ class GitDownloader extends VcsDownloader
$messages = array();
foreach ($protocols as $protocol) {
$url = $protocol . $match[1];
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $ignoredOutput)) {
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $ignoredOutput, $cwd)) {