GitDownloader: combine checkout + reset commands into a single process

use a single process instead of 3 to improve performance
main
Markus Staab 4 years ago
parent de58c5499e
commit 8dfe45a026

@ -454,15 +454,12 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
$command = sprintf('git checkout %s --', ProcessExecutor::escape($branch)); $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
$fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch)); $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
if (0 === $this->process->execute($command, $output, $path) $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
|| 0 === $this->process->execute($fallbackCommand, $output, $path)
) { if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
$command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
if (0 === $this->process->execute($command, $output, $path)) {
return null; return null;
} }
} }
}
$command = sprintf($template, ProcessExecutor::escape($gitRef)); $command = sprintf($template, ProcessExecutor::escape($gitRef));
if (0 === $this->process->execute($command, $output, $path)) { if (0 === $this->process->execute($command, $output, $path)) {

Loading…
Cancel
Save