mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-04 23:13:16 +02:00
[Nostromo] git/change-branc, Mess Detector recommendations.
This commit is contained in:
parent
0c43296d41
commit
89e780a0bf
|
@ -41,26 +41,24 @@ class ChangeBranchTask extends AbstractTask
|
|||
public function execute()
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$branch = $options['branch'];
|
||||
$branch = $this->runtime->getVar('git_revert_branch', false);
|
||||
|
||||
if (!$this->runtime->getVar('git_revert_branch', false)) {
|
||||
if ($branch === false) {
|
||||
$cmdGetCurrent = sprintf('%s branch | grep "*"', $options['path']);
|
||||
|
||||
/** @var Process $process */
|
||||
$process = $this->runtime->runLocalCommand($cmdGetCurrent);
|
||||
if ($process->isSuccessful()) {
|
||||
$initialBranch = str_replace('* ', '', trim($process->getOutput()));
|
||||
|
||||
if ($initialBranch == $branch) {
|
||||
throw new SkipException();
|
||||
} else {
|
||||
$this->runtime->setVar('git_revert_branch', $initialBranch);
|
||||
}
|
||||
} else {
|
||||
if (!$process->isSuccessful()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$branch = $this->runtime->getVar('git_revert_branch');
|
||||
|
||||
$currentBranch = str_replace('* ', '', trim($process->getOutput()));
|
||||
if ($currentBranch == $options['branch']) {
|
||||
throw new SkipException();
|
||||
}
|
||||
|
||||
$branch = $options['branch'];
|
||||
$this->runtime->setVar('git_revert_branch', $currentBranch);
|
||||
}
|
||||
|
||||
$cmdChange = sprintf('%s checkout %s', $options['path'], $branch);
|
||||
|
|
Loading…
Reference in a new issue