/** * @param string $branch * @param string $cloneUrl * @param string $absPath * @param string $pluginName */ private function installPlugin($branch, $cloneUrl, $absPath, $pluginName) { $this->gitUtil->run("clone --progress {$cloneUrl} {$absPath}"); 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); } $branch = $branch ?: 'master'; $this->ioService->writeln("Successfully checked out '{$branch}' for '{$pluginName}'\n"); }
/** * @param string $branch * @param string $absPath * @param string $pluginName */ 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}' ist Up to date"); if ($branch) { $this->gitUtil->run("checkout {$branch}"); } return; } $this->ioService->writeln("Incomming Changes:"); $this->ioService->writeln($output); $this->gitUtil->run("reset --hard HEAD"); $this->gitUtil->run("pull"); if ($branch) { $this->gitUtil->run("-C {$absPath} checkout {$branch}"); } $this->ioService->writeln("Plugin '{$pluginName}' successfully updated.\n"); return; }