mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-09-13 20:50:18 +02:00
[Nostromo] Allow to overwrite branch with command option
This commit is contained in:
parent
da3ff27e28
commit
bf458cc35c
@ -22,6 +22,7 @@ use Mage\Task\TaskFactory;
|
|||||||
use Mage\Utils;
|
use Mage\Utils;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Mage\Command\AbstractCommand;
|
use Mage\Command\AbstractCommand;
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ class DeployCommand extends AbstractCommand
|
|||||||
->setName('deploy')
|
->setName('deploy')
|
||||||
->setDescription('Deploy code to hosts')
|
->setDescription('Deploy code to hosts')
|
||||||
->addArgument('environment', InputArgument::REQUIRED, 'Name of the environment to deploy to')
|
->addArgument('environment', InputArgument::REQUIRED, 'Name of the environment to deploy to')
|
||||||
|
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Force to switch to a branch other than the one defined', false)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +91,11 @@ class DeployCommand extends AbstractCommand
|
|||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Check if Branch is forced
|
||||||
|
if ($input->getOption('branch') !== false) {
|
||||||
|
$this->runtime->setEnvironmentConfig('branch', $input->getOption('branch'));
|
||||||
|
}
|
||||||
|
|
||||||
$this->taskFactory = new TaskFactory($this->runtime);
|
$this->taskFactory = new TaskFactory($this->runtime);
|
||||||
$this->runDeployment($output);
|
$this->runDeployment($output);
|
||||||
} catch (DeploymentException $exception) {
|
} catch (DeploymentException $exception) {
|
||||||
|
@ -234,6 +234,24 @@ class Runtime
|
|||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrites an Environment configuration option
|
||||||
|
*
|
||||||
|
* @param $key
|
||||||
|
* @param $value
|
||||||
|
* @return Runtime
|
||||||
|
*/
|
||||||
|
public function setEnvironmentConfig($key, $value)
|
||||||
|
{
|
||||||
|
if (array_key_exists('environments', $this->configuration) && is_array($this->configuration['environments'])) {
|
||||||
|
if (array_key_exists($this->environment, $this->configuration['environments'])) {
|
||||||
|
$this->configuration['environments'][$this->environment][$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the working Environment
|
* Sets the working Environment
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user