From d495d10aca055dda0cbc6d953afa50182cd0b8b9 Mon Sep 17 00:00:00 2001 From: Vladimir Grigor Date: Mon, 28 Jul 2014 13:49:38 +0300 Subject: [PATCH] fixed a bug: if deploy strategy was set to "disable", release was still trying to do remote stuff. Now release step respects strategy. --- Mage/Command/BuiltIn/DeployCommand.php | 82 +++++++++++++++++--------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index ab7b427..3c48992 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -298,35 +298,9 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $tasksToRun = $this->getConfig()->getTasks(); - // Guess a Deploy Strategy - switch ($this->getConfig()->deployment('strategy', 'guess')) { - case 'disabled': - $deployStrategy = 'deployment/strategy/disabled'; - break; + $deployStrategy = $this->chooseDeployStrategy(); - case 'rsync': - $deployStrategy = 'deployment/strategy/rsync'; - break; - - case 'targz': - $deployStrategy = 'deployment/strategy/tar-gz'; - break; - - case 'git-rebase': - $deployStrategy = 'deployment/strategy/git-rebase'; - break; - - case 'guess': - default: - if ($this->getConfig()->release('enabled', false) == true) { - $deployStrategy = 'deployment/strategy/tar-gz'; - } else { - $deployStrategy = 'deployment/strategy/rsync'; - } - break; - } - - array_unshift($tasksToRun, $deployStrategy); + array_unshift($tasksToRun, $deployStrategy); if (count($tasksToRun) == 0) { Console::output('Warning! No Deployment tasks defined.', 2); @@ -381,7 +355,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $this->getConfig()->setHost($host); $this->getConfig()->setHostConfig($hostConfig); - $task = Factory::get('deployment/release', $this->getConfig(), false, AbstractTask::STAGE_DEPLOY); + $task = Factory::get($this->chooseReleaseStrategy(), $this->getConfig(), false, AbstractTask::STAGE_DEPLOY); if ($this->runTask($task, 'Releasing on host ' . $host . ' ... ')) { $completedTasks++; @@ -543,4 +517,54 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment return true; } + /** + * @return string + */ + protected function chooseDeployStrategy() + { + // Guess a Deploy Strategy + switch ($this->getConfig()->deployment('strategy', 'guess')) { + case 'disabled': + $deployStrategy = 'deployment/strategy/disabled'; + break; + + case 'rsync': + $deployStrategy = 'deployment/strategy/rsync'; + break; + + case 'targz': + $deployStrategy = 'deployment/strategy/tar-gz'; + break; + + case 'git-rebase': + $deployStrategy = 'deployment/strategy/git-rebase'; + break; + + case 'guess': + default: + if ($this->getConfig()->release('enabled', false) == true) { + $deployStrategy = 'deployment/strategy/tar-gz'; + } else { + $deployStrategy = 'deployment/strategy/rsync'; + } + break; + } + return $deployStrategy; + } + + /** + * @return string + */ + protected function chooseReleaseStrategy() + { + + if ($this->getConfig()->release('enabled', false) === true) { + $strategy = 'deployment/strategy/disabled'; + } else { + $strategy = 'deployment/release'; + } + + return $strategy; + } + }