Browse Source

PSR-2 Fixer

1.0
Andrés Montañez 10 years ago
parent
commit
a0f4920333
  1. 3
      Mage/Autoload.php
  2. 1
      Mage/Command/BuiltIn/AddCommand.php
  3. 19
      Mage/Command/BuiltIn/DeployCommand.php
  4. 1
      Mage/Command/BuiltIn/InitCommand.php
  5. 4
      Mage/Command/BuiltIn/InstallCommand.php
  6. 2
      Mage/Command/BuiltIn/ListCommand.php
  7. 1
      Mage/Command/BuiltIn/LockCommand.php
  8. 1
      Mage/Command/BuiltIn/RollbackCommand.php
  9. 1
      Mage/Command/BuiltIn/UnlockCommand.php
  10. 1
      Mage/Command/BuiltIn/UpdateCommand.php
  11. 5
      Mage/Command/BuiltIn/UpgradeCommand.php
  12. 3
      Mage/Command/Factory.php
  13. 9
      Mage/Config.php
  14. 7
      Mage/Console.php
  15. 1
      Mage/Mailer.php
  16. 17
      Mage/Task/AbstractTask.php
  17. 1
      Mage/Task/BuiltIn/Deployment/ReleaseTask.php
  18. 3
      Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php
  19. 7
      Mage/Task/BuiltIn/General/ManuallyTask.php
  20. 6
      Mage/Task/BuiltIn/Releases/ListTask.php
  21. 8
      Mage/Task/BuiltIn/Releases/RollbackTask.php
  22. 1
      Mage/Task/BuiltIn/Scm/ChangeBranchTask.php
  23. 2
      Mage/Task/Factory.php
  24. 1
      Mage/Task/RollbackException.php

3
Mage/Autoload.php

@ -31,11 +31,9 @@ class Autoload
if (strpos($className, 'Task\\') === 0) { if (strpos($className, 'Task\\') === 0) {
$baseDir = getcwd() . '/.mage/tasks'; $baseDir = getcwd() . '/.mage/tasks';
$postfix = substr($postfix, 5); $postfix = substr($postfix, 5);
} elseif (strpos($className, 'Command\\') === 0) { } elseif (strpos($className, 'Command\\') === 0) {
$baseDir = getcwd() . '/.mage/commands'; $baseDir = getcwd() . '/.mage/commands';
$postfix = substr($postfix, 8); $postfix = substr($postfix, 8);
} else { } else {
$baseDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname(__FILE__));
} }
@ -68,5 +66,4 @@ class Autoload
{ {
return is_readable($filePath); return is_readable($filePath);
} }
} }

1
Mage/Command/BuiltIn/AddCommand.php

@ -12,7 +12,6 @@ namespace Mage\Command\BuiltIn;
use Mage\Command\AbstractCommand; use Mage\Command\AbstractCommand;
use Mage\Console; use Mage\Console;
use Exception; use Exception;
/** /**

19
Mage/Command/BuiltIn/DeployCommand.php

@ -22,7 +22,6 @@ use Mage\Task\SkipException;
use Mage\Console; use Mage\Console;
use Mage\Config; use Mage\Config;
use Mage\Mailer; use Mage\Mailer;
use Exception; use Exception;
/** /**
@ -172,7 +171,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
if (self::$failedTasks > 0) { if (self::$failedTasks > 0) {
self::$deployStatus = self::FAILED; self::$deployStatus = self::FAILED;
Console::output('A total of <bold>' . self::$failedTasks . '</bold> deployment tasks failed: <red>ABORTING</red>', 1, 2); Console::output('A total of <bold>' . self::$failedTasks . '</bold> deployment tasks failed: <red>ABORTING</red>', 1, 2);
} else { } else {
// Run Deployment Tasks // Run Deployment Tasks
$this->runDeploymentTasks(); $this->runDeploymentTasks();
@ -265,7 +263,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
if (count($tasksToRun) == 0) { if (count($tasksToRun) == 0) {
Console::output('<bold>No </bold><light_cyan>' . $title . '</light_cyan> <bold>tasks defined.</bold>', 1, 3); Console::output('<bold>No </bold><light_cyan>' . $title . '</light_cyan> <bold>tasks defined.</bold>', 1, 3);
} else { } else {
Console::output('Starting <bold>' . $title . '</bold> tasks:'); Console::output('Starting <bold>' . $title . '</bold> tasks:');
@ -306,7 +303,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
if ($this->hostsCount == 0) { if ($this->hostsCount == 0) {
Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, skipping deployment tasks.</bold>', 1, 3); Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, skipping deployment tasks.</bold>', 1, 3);
} else { } else {
$this->startTimeHosts = time(); $this->startTimeHosts = time();
foreach ($hosts as $hostKey => $host) { foreach ($hosts as $hostKey => $host) {
@ -337,7 +333,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
if (count($tasksToRun) == 0) { if (count($tasksToRun) == 0) {
Console::output('<light_purple>Warning!</light_purple> <bold>No </bold><light_cyan>Deployment</light_cyan> <bold>tasks defined.</bold>', 2); Console::output('<light_purple>Warning!</light_purple> <bold>No </bold><light_cyan>Deployment</light_cyan> <bold>tasks defined.</bold>', 2);
Console::output('Deployment to <bold>' . $host . '</bold> skipped!', 1, 3); Console::output('Deployment to <bold>' . $host . '</bold> skipped!', 1, 3);
} else { } else {
foreach ($tasksToRun as $taskData) { foreach ($tasksToRun as $taskData) {
$tasks++; $tasks++;
@ -443,7 +438,8 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
} }
} }
protected function runRollbackTask(AbstractTask $task){ protected function runRollbackTask(AbstractTask $task)
{
$this->getConfig()->reload(); $this->getConfig()->reload();
$hosts = $this->getConfig()->getHosts(); $hosts = $this->getConfig()->getHosts();
@ -454,10 +450,8 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
$stagesString = implode(', ', $this->acceptedStagesToRollback); $stagesString = implode(', ', $this->acceptedStagesToRollback);
Console::output("<light_purple>Warning!</light_purple> <bold>Rollback during deployment can be called only at the stages: $stagesString <bold>", 1); Console::output("<light_purple>Warning!</light_purple> <bold>Rollback during deployment can be called only at the stages: $stagesString <bold>", 1);
Console::output("<bold>Rollback:<bold> <red>ABORTING</red>", 1, 3); Console::output("<bold>Rollback:<bold> <red>ABORTING</red>", 1, 3);
} elseif (count($hosts) == 0) { } elseif (count($hosts) == 0) {
Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3); Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3);
} else { } else {
$result = true; $result = true;
foreach ($hosts as $hostKey => $host) { foreach ($hosts as $hostKey => $host) {
@ -482,7 +476,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
); );
$task->init(); $task->init();
$result = $task->run() && $result; $result = $task->run() && $result;
} }
return $result; return $result;
} }
@ -506,7 +499,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
Console::output($title, 2, 0); Console::output($title, 2, 0);
$runTask = true; $runTask = true;
if (($task instanceOf SkipOnOverride) && $this->getConfig()->getParameter('overrideRelease', false)) { if (($task instanceof SkipOnOverride) && $this->getConfig()->getParameter('overrideRelease', false)) {
$runTask = false; $runTask = false;
} }
@ -517,7 +510,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
if ($result === true) { if ($result === true) {
Console::output('<green>OK</green>', 0); Console::output('<green>OK</green>', 0);
$result = true; $result = true;
} else { } else {
Console::output('<red>FAIL</red>', 0); Console::output('<red>FAIL</red>', 0);
$result = false; $result = false;
@ -526,15 +518,12 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
Console::output('<red>FAIL, Rollback catched</red> [Message: ' . $e->getMessage() . ']', 0); Console::output('<red>FAIL, Rollback catched</red> [Message: ' . $e->getMessage() . ']', 0);
$this->runRollbackTask($task); $this->runRollbackTask($task);
$result = false; $result = false;
} catch (ErrorWithMessageException $e) { } catch (ErrorWithMessageException $e) {
Console::output('<red>FAIL</red> [Message: ' . $e->getMessage() . ']', 0); Console::output('<red>FAIL</red> [Message: ' . $e->getMessage() . ']', 0);
$result = false; $result = false;
} catch (SkipException $e) { } catch (SkipException $e) {
Console::output('<yellow>SKIPPED</yellow>', 0); Console::output('<yellow>SKIPPED</yellow>', 0);
$result = true; $result = true;
} catch (Exception $e) { } catch (Exception $e) {
Console::output('<red>FAIL</red>', 0); Console::output('<red>FAIL</red>', 0);
$result = false; $result = false;
@ -645,7 +634,6 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
*/ */
protected function chooseReleaseStrategy() protected function chooseReleaseStrategy()
{ {
if ($this->getConfig()->release('enabled', self::DEFAULT_RELEASE_IS_ENABLED) if ($this->getConfig()->release('enabled', self::DEFAULT_RELEASE_IS_ENABLED)
&& $this->getConfig()->deployment('strategy', self::DEFAULT_DEPLOY_STRATEGY) !== self::DEPLOY_STRATEGY_DISABLED && $this->getConfig()->deployment('strategy', self::DEFAULT_DEPLOY_STRATEGY) !== self::DEPLOY_STRATEGY_DISABLED
) { ) {
@ -656,5 +644,4 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
return $strategy; return $strategy;
} }
} }

1
Mage/Command/BuiltIn/InitCommand.php

@ -51,7 +51,6 @@ class InitCommand extends AbstractCommand
Console::output('<light_green>Success!!</light_green> The configuration for <bold>Magallanes</bold> has been generated at <blue>.mage</blue> directory.'); Console::output('<light_green>Success!!</light_green> The configuration for <bold>Magallanes</bold> has been generated at <blue>.mage</blue> directory.');
Console::output('<bold>Please!! Review and adjust the configuration.</bold>', 2, 2); Console::output('<bold>Please!! Review and adjust the configuration.</bold>', 2, 2);
$exitCode = 0; $exitCode = 0;
} else { } else {
Console::output('<light_red>Error!!</light_red> Unable to generate the configuration.', 1, 2); Console::output('<light_red>Error!!</light_red> Unable to generate the configuration.', 1, 2);
} }

4
Mage/Command/BuiltIn/InstallCommand.php

@ -44,7 +44,6 @@ class InstallCommand extends AbstractCommand
// Chck if it is a system wide install the user is root // Chck if it is a system wide install the user is root
} elseif ($systemWide && (getenv('LOGNAME') != 'root')) { } elseif ($systemWide && (getenv('LOGNAME') != 'root')) {
Console::output('<red>Failure: you have to be root to perform a system wide install.</red>', 0, 2); Console::output('<red>Failure: you have to be root to perform a system wide install.</red>', 0, 2);
} else { } else {
$destinationDir = $baseDir . '/' . $installDir; $destinationDir = $baseDir . '/' . $installDir;
if (!is_dir($destinationDir)) { if (!is_dir($destinationDir)) {
@ -104,7 +103,6 @@ class InstallCommand extends AbstractCommand
$from . DIRECTORY_SEPARATOR . $file, $from . DIRECTORY_SEPARATOR . $file,
$to . DIRECTORY_SEPARATOR . $file $to . DIRECTORY_SEPARATOR . $file
); );
} else { } else {
copy( copy(
$from . DIRECTORY_SEPARATOR . $file, $from . DIRECTORY_SEPARATOR . $file,
@ -114,10 +112,8 @@ class InstallCommand extends AbstractCommand
} }
} }
return true; return true;
} elseif (is_file($from)) { } elseif (is_file($from)) {
return copy($from, $to); return copy($from, $to);
} else { } else {
return false; return false;
} }

2
Mage/Command/BuiltIn/ListCommand.php

@ -12,7 +12,6 @@ namespace Mage\Command\BuiltIn;
use Mage\Command\AbstractCommand; use Mage\Command\AbstractCommand;
use Mage\Console; use Mage\Console;
use Exception; use Exception;
/** /**
@ -73,7 +72,6 @@ class ListCommand extends AbstractCommand
} }
Console::output('', 1, 1); Console::output('', 1, 1);
$exitCode = 0; $exitCode = 0;
} else { } else {
Console::output('<bold>You don\'t have any environment configured.</bold>', 1, 2); Console::output('<bold>You don\'t have any environment configured.</bold>', 1, 2);
} }

1
Mage/Command/BuiltIn/LockCommand.php

@ -58,5 +58,4 @@ class LockCommand extends AbstractCommand implements RequiresEnvironment
return 0; return 0;
} }
} }

1
Mage/Command/BuiltIn/RollbackCommand.php

@ -48,7 +48,6 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment
if (count($hosts) == 0) { if (count($hosts) == 0) {
Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3); Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3);
} else { } else {
$result = true; $result = true;
foreach ($hosts as $hostKey => $host) { foreach ($hosts as $hostKey => $host) {

1
Mage/Command/BuiltIn/UnlockCommand.php

@ -41,5 +41,4 @@ class UnlockCommand extends AbstractCommand implements RequiresEnvironment
return 0; return 0;
} }
} }

1
Mage/Command/BuiltIn/UpdateCommand.php

@ -38,7 +38,6 @@ class UpdateCommand extends AbstractCommand
if ($result === true) { if ($result === true) {
Console::output('<green>OK</green>' . PHP_EOL, 0); Console::output('<green>OK</green>' . PHP_EOL, 0);
$exitCode = 0; $exitCode = 0;
} else { } else {
Console::output('<red>FAIL</red>' . PHP_EOL, 0); Console::output('<red>FAIL</red>' . PHP_EOL, 0);
} }

5
Mage/Command/BuiltIn/UpgradeCommand.php

@ -50,7 +50,6 @@ class UpgradeCommand extends AbstractCommand
if ($user != 'root' && $user != $owner) { if ($user != 'root' && $user != $owner) {
Console::output('<red>FAIL</red>', 0, 1); Console::output('<red>FAIL</red>', 0, 1);
Console::output('You need to be the <bold>' . $owner . '</bold> user to perform the upgrade, or <bold>root</bold>.', 2); Console::output('You need to be the <bold>' . $owner . '</bold> user to perform the upgrade, or <bold>root</bold>.', 2);
} else { } else {
// Check version // Check version
$version = json_decode(file_get_contents(self::UPGRADE)); $version = json_decode(file_get_contents(self::UPGRADE));
@ -61,19 +60,16 @@ class UpgradeCommand extends AbstractCommand
Console::output('<yellow>SKIP</yellow>', 0, 1); Console::output('<yellow>SKIP</yellow>', 0, 1);
Console::output('Your current version is up to date.', 2); Console::output('Your current version is up to date.', 2);
$exitCode = 0; $exitCode = 0;
} elseif ($versionCompare == 1) { } elseif ($versionCompare == 1) {
Console::output('<yellow>SKIP</yellow>', 0, 1); Console::output('<yellow>SKIP</yellow>', 0, 1);
Console::output('Your current version is newer.', 2); Console::output('Your current version is newer.', 2);
$exitCode = 0; $exitCode = 0;
} elseif ($versionCompare == -1) { } elseif ($versionCompare == -1) {
// Download Package // Download Package
$tarball = file_get_contents(str_replace('{version}', $version->latest, self::DOWNLOAD)); $tarball = file_get_contents(str_replace('{version}', $version->latest, self::DOWNLOAD));
if ($tarball === false) { if ($tarball === false) {
Console::output('<red>FAIL</red>', 0, 1); Console::output('<red>FAIL</red>', 0, 1);
Console::output('Corrupted download.', 2); Console::output('Corrupted download.', 2);
} else { } else {
$tarballFile = tempnam('/tmp', 'magallanes_download'); $tarballFile = tempnam('/tmp', 'magallanes_download');
rename($tarballFile, $tarballFile . '.tar.gz'); rename($tarballFile, $tarballFile . '.tar.gz');
@ -87,7 +83,6 @@ class UpgradeCommand extends AbstractCommand
Console::output('<green>OK</green>', 0, 1); Console::output('<green>OK</green>', 0, 1);
$exitCode = 0; $exitCode = 0;
} }
} else { } else {
Console::output('<red>FAIL</red>', 0, 1); Console::output('<red>FAIL</red>', 0, 1);
Console::output('Invalid version.', 2); Console::output('Invalid version.', 2);

3
Mage/Command/Factory.php

@ -12,7 +12,6 @@ namespace Mage\Command;
use Mage\Command\AbstractCommand; use Mage\Command\AbstractCommand;
use Mage\Config; use Mage\Config;
use Exception; use Exception;
/** /**
@ -52,7 +51,7 @@ class Factory
/** @var AbstractCommand $instance */ /** @var AbstractCommand $instance */
// TODO dependencies like $config should be injected into constructor // TODO dependencies like $config should be injected into constructor
$instance = new $className; $instance = new $className;
if (! $instance instanceOf AbstractCommand) { if (! $instance instanceof AbstractCommand) {
// TODO use a custom exception // TODO use a custom exception
throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.'); throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.');
} }

9
Mage/Config.php

@ -75,7 +75,6 @@ class Config
foreach ($arguments as $argument) { foreach ($arguments as $argument) {
if (preg_match('/to:[\w]+/i', $argument)) { if (preg_match('/to:[\w]+/i', $argument)) {
$this->environment = str_replace('to:', '', $argument); $this->environment = str_replace('to:', '', $argument);
} elseif (preg_match('/--[\w]+/i', $argument)) { } elseif (preg_match('/--[\w]+/i', $argument)) {
$optionValue = explode('=', substr($argument, 2)); $optionValue = explode('=', substr($argument, 2));
if (count($optionValue) == 1) { if (count($optionValue) == 1) {
@ -129,11 +128,9 @@ class Config
*/ */
protected function loadEnvironment($filePath) protected function loadEnvironment($filePath)
{ {
$settings = $this->parseConfigFile($filePath); $settings = $this->parseConfigFile($filePath);
return $settings; return $settings;
} }
/** /**
@ -154,7 +151,6 @@ class Config
} catch (ConfigNotFoundException $e) { } catch (ConfigNotFoundException $e) {
throw new RequiredConfigNotFoundException("Not found required config $configFilePath for environment $environment", 0, $e); throw new RequiredConfigNotFoundException("Not found required config $configFilePath for environment $environment", 0, $e);
} }
} }
} }
@ -165,8 +161,9 @@ class Config
*/ */
protected function isRunInSpecialMode(array $parameters) protected function isRunInSpecialMode(array $parameters)
{ {
if (empty($parameters)) if (empty($parameters)) {
return true; return true;
}
foreach ($parameters as $parameter) { foreach ($parameters as $parameter) {
if (isset(Console::$paramsNotRequiringEnvironment[$parameter])) { if (isset(Console::$paramsNotRequiringEnvironment[$parameter])) {
return true; return true;
@ -605,7 +602,6 @@ class Config
$fileContent = stream_get_contents($handle); $fileContent = stream_get_contents($handle);
$hosts = json_decode($fileContent); $hosts = json_decode($fileContent);
} catch (Exception $e) { } catch (Exception $e) {
rewind($handle); rewind($handle);
//do it old-style: one host per line //do it old-style: one host per line
while (($host = stream_get_line($handle, self::HOST_NAME_LENGTH)) !== false) { while (($host = stream_get_line($handle, self::HOST_NAME_LENGTH)) !== false) {
@ -618,5 +614,4 @@ class Config
return $hosts; return $hosts;
} }
} }

7
Mage/Console.php

@ -13,7 +13,6 @@ namespace Mage;
use Mage\Command\Factory; use Mage\Command\Factory;
use Mage\Command\RequiresEnvironment; use Mage\Command\RequiresEnvironment;
use Mage\Console\Colors; use Mage\Console\Colors;
use Exception; use Exception;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use SplFileInfo; use SplFileInfo;
@ -95,7 +94,6 @@ class Console
try { try {
// Load configuration // Load configuration
$config->load($arguments); $config->load($arguments);
} catch (Exception $exception) { } catch (Exception $exception) {
$configError = $exception->getMessage(); $configError = $exception->getMessage();
} }
@ -119,7 +117,6 @@ class Console
if ($showGreetings) { if ($showGreetings) {
if (!self::$logEnabled) { if (!self::$logEnabled) {
self::output('Starting <blue>Magallanes</blue>', 0, 2); self::output('Starting <blue>Magallanes</blue>', 0, 2);
} else { } else {
self::output('Starting <blue>Magallanes</blue>', 0, 1); self::output('Starting <blue>Magallanes</blue>', 0, 1);
self::log("Logging enabled"); self::log("Logging enabled");
@ -130,13 +127,12 @@ class Console
// Run Command - Check if there is a Configuration Error // Run Command - Check if there is a Configuration Error
if ($configError !== false) { if ($configError !== false) {
self::output('<red>' . $configError . '</red>', 1, 2); self::output('<red>' . $configError . '</red>', 1, 2);
} else { } else {
// Run Command and check for Command Requirements // Run Command and check for Command Requirements
try { try {
$command = Factory::get($commandName, $config); $command = Factory::get($commandName, $config);
if ($command instanceOf RequiresEnvironment) { if ($command instanceof RequiresEnvironment) {
if ($config->getEnvironment() === false) { if ($config->getEnvironment() === false) {
throw new Exception('You must specify an environment for this command.'); throw new Exception('You must specify an environment for this command.');
} }
@ -310,5 +306,4 @@ class Console
|| self::$config->general('verbose_logging') || self::$config->general('verbose_logging')
|| self::$config->environmentConfig('verbose_logging', false); || self::$config->environmentConfig('verbose_logging', false);
} }
} }

1
Mage/Mailer.php

@ -10,7 +10,6 @@
namespace Mage; namespace Mage;
/** /**
* Mailer Helper. * Mailer Helper.
* *

17
Mage/Task/AbstractTask.php

@ -13,7 +13,6 @@ namespace Mage\Task;
use Mage\Console; use Mage\Console;
use Mage\Config; use Mage\Config;
use Mage\Task\Releases\IsReleaseAware; use Mage\Task\Releases\IsReleaseAware;
use Exception; use Exception;
/** /**
@ -75,7 +74,7 @@ abstract class AbstractTask
* Returns the Title of the Task * Returns the Title of the Task
* @return string * @return string
*/ */
public abstract function getName(); abstract public function getName();
/** /**
* Runs the task * Runs the task
@ -85,7 +84,7 @@ abstract class AbstractTask
* @throws ErrorWithMessageException * @throws ErrorWithMessageException
* @throws SkipException * @throws SkipException
*/ */
public abstract function run(); abstract public function run();
/** /**
* Task Constructor * Task Constructor
@ -95,7 +94,7 @@ abstract class AbstractTask
* @param string $stage * @param string $stage
* @param array $parameters * @param array $parameters
*/ */
public final function __construct(Config $config, $inRollback = false, $stage = null, $parameters = array()) final public function __construct(Config $config, $inRollback = false, $stage = null, $parameters = array())
{ {
$this->config = $config; $this->config = $config;
$this->inRollback = $inRollback; $this->inRollback = $inRollback;
@ -167,7 +166,7 @@ abstract class AbstractTask
* @param string $output * @param string $output
* @return boolean * @return boolean
*/ */
protected final function runCommandLocal($command, &$output = null) final protected function runCommandLocal($command, &$output = null)
{ {
return Console::executeCommand($command, $output); return Console::executeCommand($command, $output);
} }
@ -179,19 +178,17 @@ abstract class AbstractTask
* @param boolean $cdToDirectoryFirst * @param boolean $cdToDirectoryFirst
* @return boolean * @return boolean
*/ */
protected final function runCommandRemote($command, &$output = null, $cdToDirectoryFirst = true) final protected function runCommandRemote($command, &$output = null, $cdToDirectoryFirst = true)
{ {
if ($this->getConfig()->release('enabled', false) === true) { if ($this->getConfig()->release('enabled', false) === true) {
if ($this instanceOf IsReleaseAware) { if ($this instanceof IsReleaseAware) {
$releasesDirectory = ''; $releasesDirectory = '';
} else { } else {
$releasesDirectory = '/' $releasesDirectory = '/'
. $this->getConfig()->release('directory', 'releases') . $this->getConfig()->release('directory', 'releases')
. '/' . '/'
. $this->getConfig()->getReleaseId(); . $this->getConfig()->getReleaseId();
} }
} else { } else {
$releasesDirectory = ''; $releasesDirectory = '';
} }
@ -223,7 +220,7 @@ abstract class AbstractTask
* @param string $output * @param string $output
* @return boolean * @return boolean
*/ */
protected final function runCommand($command, &$output = null) final protected function runCommand($command, &$output = null)
{ {
if ($this->getStage() == self::STAGE_DEPLOY || $this->getStage() == self::STAGE_POST_RELEASE) { if ($this->getStage() == self::STAGE_DEPLOY || $this->getStage() == self::STAGE_POST_RELEASE) {
return $this->runCommandRemote($command, $output); return $this->runCommandRemote($command, $output);

1
Mage/Task/BuiltIn/Deployment/ReleaseTask.php

@ -98,7 +98,6 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
} }
return $result; return $result;
} else { } else {
return false; return false;
} }

3
Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php

@ -46,7 +46,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
$this->checkOverrideRelease(); $this->checkOverrideRelease();
$excludes = $this->getExcludes(); $excludes = $this->getExcludes();
$excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');; $excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');
;
// If we are working with releases // If we are working with releases
$deployToDirectory = $this->getConfig()->deployment('to'); $deployToDirectory = $this->getConfig()->deployment('to');

7
Mage/Task/BuiltIn/General/ManuallyTask.php

@ -30,7 +30,8 @@ use Mage\Task\AbstractTask;
* *
* @author Samuel Chiriluta <samuel4x4@gmail.com> * @author Samuel Chiriluta <samuel4x4@gmail.com>
*/ */
class ManuallyTask extends AbstractTask { class ManuallyTask extends AbstractTask
{
/** /**
* (non-PHPdoc) * (non-PHPdoc)
@ -50,12 +51,10 @@ class ManuallyTask extends AbstractTask {
$commands = $this->getParameters(); $commands = $this->getParameters();
foreach ($commands as $command) foreach ($commands as $command) {
{
$result = $result && $this->runCommand($command); $result = $result && $this->runCommand($command);
} }
return $result; return $result;
} }
} }

6
Mage/Task/BuiltIn/Releases/ListTask.php

@ -13,7 +13,6 @@ namespace Mage\Task\BuiltIn\Releases;
use Mage\Console; use Mage\Console;
use Mage\Task\AbstractTask; use Mage\Task\AbstractTask;
use Mage\Task\Releases\IsReleaseAware; use Mage\Task\Releases\IsReleaseAware;
use DateTime; use DateTime;
/** /**
@ -87,7 +86,6 @@ class ListTask extends AbstractTask implements IsReleaseAware
Console::output(''); Console::output('');
return $result; return $result;
} else { } else {
Console::output(''); Console::output('');
return false; return false;
@ -109,7 +107,6 @@ class ListTask extends AbstractTask implements IsReleaseAware
if ($diff->format('%a') <= 7) { if ($diff->format('%a') <= 7) {
if ($diff->format('%d') == 7) { if ($diff->format('%d') == 7) {
$textDiff = ' [a week ago] '; $textDiff = ' [a week ago] ';
} elseif ($diff->format('%d') > 0 && $diff->format('%d') < 7) { } elseif ($diff->format('%d') > 0 && $diff->format('%d') < 7) {
$days = $diff->format('%d'); $days = $diff->format('%d');
if ($days <= 1) { if ($days <= 1) {
@ -117,7 +114,6 @@ class ListTask extends AbstractTask implements IsReleaseAware
} else { } else {
$textDiff = ' [' . $days . ' days ago] '; $textDiff = ' [' . $days . ' days ago] ';
} }
} elseif ($diff->format('%d') == 0 && $diff->format('%h') > 0) { } elseif ($diff->format('%d') == 0 && $diff->format('%h') > 0) {
$hours = $diff->format('%h'); $hours = $diff->format('%h');
if ($hours <= 1) { if ($hours <= 1) {
@ -125,7 +121,6 @@ class ListTask extends AbstractTask implements IsReleaseAware
} else { } else {
$textDiff = ' [' . $hours . ' hours ago] '; $textDiff = ' [' . $hours . ' hours ago] ';
} }
} elseif ($diff->format('%d') == 0 && $diff->format('%h') == 0) { } elseif ($diff->format('%d') == 0 && $diff->format('%h') == 0) {
$minutes = $diff->format('%i'); $minutes = $diff->format('%i');
if ($minutes <= 1) { if ($minutes <= 1) {
@ -133,7 +128,6 @@ class ListTask extends AbstractTask implements IsReleaseAware
} else { } else {
$textDiff = ' [' . $minutes . ' minutes ago] '; $textDiff = ' [' . $minutes . ' minutes ago] ';
} }
} elseif ($diff->format('%d') == 0 && $diff->format('%h') == 0 && $diff->format('%i') == 0) { } elseif ($diff->format('%d') == 0 && $diff->format('%h') == 0 && $diff->format('%i') == 0) {
$seconds = $diff->format('%s'); $seconds = $diff->format('%s');
if ($seconds < 10) { if ($seconds < 10) {

8
Mage/Task/BuiltIn/Releases/RollbackTask.php

@ -61,7 +61,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
if (count($releases) == 0) { if (count($releases) == 0) {
Console::output('Release are not available for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>'); Console::output('Release are not available for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>');
} else { } else {
rsort($releases); rsort($releases);
$deleteCurrent = $this->getConfig()->getParameter('deleteCurrent', $deleteCurrent = $this->getConfig()->getParameter('deleteCurrent',
@ -74,7 +73,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
if ($this->getReleaseId() == '') { if ($this->getReleaseId() == '') {
$releaseId = $releases[0]; $releaseId = $releases[0];
$releaseIsAvailable = true; $releaseIsAvailable = true;
} elseif ($this->getReleaseId() <= 0) { } elseif ($this->getReleaseId() <= 0) {
$index = $this->getReleaseId() * -1; $index = $this->getReleaseId() * -1;
if (isset($releases[$index])) { if (isset($releases[$index])) {
@ -92,7 +90,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
if (!$releaseIsAvailable) { if (!$releaseIsAvailable) {
Console::output('Release <bold>' . $this->getReleaseId() . '</bold> is invalid or unavailable for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>'); Console::output('Release <bold>' . $this->getReleaseId() . '</bold> is invalid or unavailable for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>');
} else { } else {
Console::output('Rollback release on <bold>' . $this->getConfig()->getHost() . '</bold>'); Console::output('Rollback release on <bold>' . $this->getConfig()->getHost() . '</bold>');
$rollbackTo = $releasesDirectory . '/' . $releaseId; $rollbackTo = $releasesDirectory . '/' . $releaseId;
@ -116,7 +113,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
$task->init(); $task->init();
Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false); Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false);
if ($task instanceOf RollbackAware) { if ($task instanceof RollbackAware) {
/* @var $task AbstractTask */ /* @var $task AbstractTask */
$tasks++; $tasks++;
$result = $task->run(); $result = $task->run();
@ -166,7 +163,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
$task->init(); $task->init();
Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false); Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false);
if ($task instanceOf RollbackAware) { if ($task instanceof RollbackAware) {
/* @var $task AbstractTask */ /* @var $task AbstractTask */
$tasks++; $tasks++;
$result = $task->run(); $result = $task->run();
@ -193,7 +190,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
} }
return $result; return $result;
} else { } else {
return false; return false;
} }

1
Mage/Task/BuiltIn/Scm/ChangeBranchTask.php

@ -69,7 +69,6 @@ class ChangeBranchTask extends AbstractTask
if ($this->getParameter('_changeBranchRevert', false)) { if ($this->getParameter('_changeBranchRevert', false)) {
$command = $preCommand . 'git checkout ' . self::$startingBranch; $command = $preCommand . 'git checkout ' . self::$startingBranch;
$result = $this->runCommandLocal($command); $result = $this->runCommandLocal($command);
} else { } else {
$command = $preCommand . 'git branch | grep \'*\' | cut -d\' \' -f 2'; $command = $preCommand . 'git branch | grep \'*\' | cut -d\' \' -f 2';
$currentBranch = 'master'; $currentBranch = 'master';

2
Mage/Task/Factory.php

@ -12,7 +12,6 @@ namespace Mage\Task;
use Mage\Config; use Mage\Config;
use Mage\Task\AbstractTask; use Mage\Task\AbstractTask;
use Exception; use Exception;
/** /**
@ -48,7 +47,6 @@ class Factory
if (strpos($taskName, '/') === false) { if (strpos($taskName, '/') === false) {
$className = 'Task\\' . $taskName; $className = 'Task\\' . $taskName;
} else { } else {
$className = 'Mage\\Task\\BuiltIn\\' . str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))) . 'Task'; $className = 'Mage\\Task\\BuiltIn\\' . str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))) . 'Task';
} }

1
Mage/Task/RollbackException.php

@ -19,5 +19,4 @@ use Exception;
*/ */
class RollbackException extends Exception class RollbackException extends Exception
{ {
} }
Loading…
Cancel
Save