private function updatePlugin($branch, $absPath, $pluginName)
{
$this->ioService->writeln("Plugin is already installed");
$this->utilities->changeDir($absPath);
$this->gitUtil->run("fetch --progress origin");
$output = $this->gitUtil->run("log HEAD..origin/master --oneline");
if (trim($output) === '') {
$this->ioService->writeln("Plugin '{$pluginName}' is up to date");
if ($branch) {
$this->gitUtil->run("checkout {$branch}");
}
return;
}
$this->ioService->writeln("Incoming changes:");
$this->ioService->writeln($output);
$this->gitUtil->run("reset --hard HEAD");
$this->gitUtil->run("pull");
if ($branch) {
// the CWD change is a fix for older versions of GIT which do not support the -C flag
$cwd = getcwd();
$this->utilities->changeDir($absPath);
$this->gitUtil->run("checkout {$branch}");
$this->utilities->changeDir($cwd);
}
$this->ioService->writeln("Plugin '{$pluginName}' successfully updated.\n");
return;
}