|
|
@ -90,8 +90,23 @@ class GitDownloader extends VcsDownloader
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function cleanChanges($path, $update)
|
|
|
|
protected function cleanChanges($path, $update)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
$discardChanges = $this->config->get('discard-changes');
|
|
|
|
if (!$this->io->isInteractive()) {
|
|
|
|
if (!$this->io->isInteractive()) {
|
|
|
|
|
|
|
|
switch ($discardChanges) {
|
|
|
|
|
|
|
|
case 'true':
|
|
|
|
|
|
|
|
return $this->discardChanges($path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'stash':
|
|
|
|
|
|
|
|
if (!$update) {
|
|
|
|
return parent::cleanChanges($path, $update);
|
|
|
|
return parent::cleanChanges($path, $update);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return $this->stashChanges($path);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'false':
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return parent::cleanChanges($path, $update);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!$changes = $this->getLocalChanges($path)) {
|
|
|
|
if (!$changes = $this->getLocalChanges($path)) {
|
|
|
@ -110,9 +125,7 @@ class GitDownloader extends VcsDownloader
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
switch ($this->io->ask(' <info>Discard changes [y,n,v,'.($update ? 's,' : '').'?]?</info> ', '?')) {
|
|
|
|
switch ($this->io->ask(' <info>Discard changes [y,n,v,'.($update ? 's,' : '').'?]?</info> ', '?')) {
|
|
|
|
case 'y':
|
|
|
|
case 'y':
|
|
|
|
if (0 !== $this->process->execute('git reset --hard', $output, $path)) {
|
|
|
|
$this->discardChanges($path);
|
|
|
|
throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break 2;
|
|
|
|
break 2;
|
|
|
|
|
|
|
|
|
|
|
|
case 's':
|
|
|
|
case 's':
|
|
|
@ -120,11 +133,7 @@ class GitDownloader extends VcsDownloader
|
|
|
|
goto help;
|
|
|
|
goto help;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (0 !== $this->process->execute('git stash', $output, $path)) {
|
|
|
|
$this->stashChanges($path);
|
|
|
|
throw new \RuntimeException("Could not stash changes\n\n:".$this->process->getErrorOutput());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->hasStashedChanges = true;
|
|
|
|
|
|
|
|
break 2;
|
|
|
|
break 2;
|
|
|
|
|
|
|
|
|
|
|
|
case 'n':
|
|
|
|
case 'n':
|
|
|
@ -369,4 +378,28 @@ class GitDownloader extends VcsDownloader
|
|
|
|
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param $path
|
|
|
|
|
|
|
|
* @throws \RuntimeException
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected function discardChanges($path)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (0 !== $this->process->execute('git reset --hard', $output, $path)) {
|
|
|
|
|
|
|
|
throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param $path
|
|
|
|
|
|
|
|
* @throws \RuntimeException
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected function stashChanges($path)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (0 !== $this->process->execute('git stash', $output, $path)) {
|
|
|
|
|
|
|
|
throw new \RuntimeException("Could not stash changes\n\n:".$this->process->getErrorOutput());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->hasStashedChanges = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|