Browse Source

[Nostromo] git/change-branc, Mess Detector recommendations.

pull/1/head
Andrés Montañez 8 years ago
parent
commit
89e780a0bf
  1. 22
      src/Mage/Task/BuiltIn/Git/ChangeBranchTask.php

22
src/Mage/Task/BuiltIn/Git/ChangeBranchTask.php

@ -41,26 +41,24 @@ class ChangeBranchTask extends AbstractTask
public function execute() public function execute()
{ {
$options = $this->getOptions(); $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']); $cmdGetCurrent = sprintf('%s branch | grep "*"', $options['path']);
/** @var Process $process */ /** @var Process $process */
$process = $this->runtime->runLocalCommand($cmdGetCurrent); $process = $this->runtime->runLocalCommand($cmdGetCurrent);
if ($process->isSuccessful()) { if (!$process->isSuccessful()) {
$initialBranch = str_replace('* ', '', trim($process->getOutput())); return false;
}
if ($initialBranch == $branch) { $currentBranch = str_replace('* ', '', trim($process->getOutput()));
if ($currentBranch == $options['branch']) {
throw new SkipException(); throw new SkipException();
} else {
$this->runtime->setVar('git_revert_branch', $initialBranch);
}
} else {
return false;
} }
} else {
$branch = $this->runtime->getVar('git_revert_branch'); $branch = $options['branch'];
$this->runtime->setVar('git_revert_branch', $currentBranch);
} }
$cmdChange = sprintf('%s checkout %s', $options['path'], $branch); $cmdChange = sprintf('%s checkout %s', $options['path'], $branch);

Loading…
Cancel
Save