mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-09-08 14:28:57 +02:00
PSR-2 Fixer
This commit is contained in:
@@ -13,7 +13,6 @@ namespace Mage\Task;
|
||||
use Mage\Console;
|
||||
use Mage\Config;
|
||||
use Mage\Task\Releases\IsReleaseAware;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@@ -75,7 +74,7 @@ abstract class AbstractTask
|
||||
* Returns the Title of the Task
|
||||
* @return string
|
||||
*/
|
||||
public abstract function getName();
|
||||
abstract public function getName();
|
||||
|
||||
/**
|
||||
* Runs the task
|
||||
@@ -85,7 +84,7 @@ abstract class AbstractTask
|
||||
* @throws ErrorWithMessageException
|
||||
* @throws SkipException
|
||||
*/
|
||||
public abstract function run();
|
||||
abstract public function run();
|
||||
|
||||
/**
|
||||
* Task Constructor
|
||||
@@ -95,7 +94,7 @@ abstract class AbstractTask
|
||||
* @param string $stage
|
||||
* @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->inRollback = $inRollback;
|
||||
@@ -167,7 +166,7 @@ abstract class AbstractTask
|
||||
* @param string $output
|
||||
* @return boolean
|
||||
*/
|
||||
protected final function runCommandLocal($command, &$output = null)
|
||||
final protected function runCommandLocal($command, &$output = null)
|
||||
{
|
||||
return Console::executeCommand($command, $output);
|
||||
}
|
||||
@@ -179,19 +178,17 @@ abstract class AbstractTask
|
||||
* @param boolean $cdToDirectoryFirst
|
||||
* @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 instanceOf IsReleaseAware) {
|
||||
if ($this instanceof IsReleaseAware) {
|
||||
$releasesDirectory = '';
|
||||
|
||||
} else {
|
||||
$releasesDirectory = '/'
|
||||
. $this->getConfig()->release('directory', 'releases')
|
||||
. '/'
|
||||
. $this->getConfig()->getReleaseId();
|
||||
}
|
||||
|
||||
} else {
|
||||
$releasesDirectory = '';
|
||||
}
|
||||
@@ -202,7 +199,7 @@ abstract class AbstractTask
|
||||
$localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' '
|
||||
. '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
|
||||
. $this->getConfig()->getConnectTimeoutOption()
|
||||
. ( $this->getConfig()->deployment('user') != '' ? $this->getConfig()->deployment('user') . '@' : '' )
|
||||
. ($this->getConfig()->deployment('user') != '' ? $this->getConfig()->deployment('user') . '@' : '')
|
||||
. $this->getConfig()->getHostName();
|
||||
|
||||
$remoteCommand = str_replace('"', '\"', $command);
|
||||
@@ -223,7 +220,7 @@ abstract class AbstractTask
|
||||
* @param string $output
|
||||
* @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) {
|
||||
return $this->runCommandRemote($command, $output);
|
||||
|
||||
@@ -98,7 +98,6 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
||||
. $this->excludes($excludes) . ' '
|
||||
. $this->excludesListFile($excludesListFilePath) . ' '
|
||||
. $this->getConfig()->deployment('from') . ' '
|
||||
. ( $this->getConfig()->deployment('user') ? $this->getConfig()->deployment('user') . '@' : '' )
|
||||
. ($this->getConfig()->deployment('user') ? $this->getConfig()->deployment('user') . '@' : '')
|
||||
. $this->getConfig()->getHostName() . ':' . $deployToDirectory;
|
||||
|
||||
$result = $this->runCommandLocal($command);
|
||||
@@ -132,7 +132,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
||||
protected function excludesListFile($excludesFile)
|
||||
{
|
||||
$excludesListFileRsync = '';
|
||||
if(!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) {
|
||||
if (!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) {
|
||||
$excludesListFileRsync = ' --exclude-from=' . $excludesFile;
|
||||
}
|
||||
return $excludesListFileRsync;
|
||||
|
||||
@@ -46,7 +46,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
||||
$this->checkOverrideRelease();
|
||||
|
||||
$excludes = $this->getExcludes();
|
||||
$excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');;
|
||||
$excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');
|
||||
;
|
||||
|
||||
// If we are working with releases
|
||||
$deployToDirectory = $this->getConfig()->deployment('to');
|
||||
@@ -131,7 +132,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
||||
protected function excludesListFile($excludesFile)
|
||||
{
|
||||
$excludesListFileRsync = '';
|
||||
if(!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) {
|
||||
if (!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) {
|
||||
$excludesListFileRsync = ' --exclude-from=' . $excludesFile;
|
||||
}
|
||||
return $excludesListFileRsync;
|
||||
|
||||
@@ -158,7 +158,7 @@ class PermissionsTask extends AbstractTask
|
||||
'R' => $this->recursive
|
||||
);
|
||||
|
||||
foreach($options as $option => $apply) {
|
||||
foreach ($options as $option => $apply) {
|
||||
if ($apply === true) {
|
||||
$optionsForCmd .= $option;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* Task for running multiple custom commands setting them manually
|
||||
*
|
||||
*
|
||||
* Example of usage:
|
||||
*
|
||||
*
|
||||
* tasks:
|
||||
* on-deploy:
|
||||
* - scm/force-update
|
||||
@@ -30,7 +30,8 @@ use Mage\Task\AbstractTask;
|
||||
*
|
||||
* @author Samuel Chiriluta <samuel4x4@gmail.com>
|
||||
*/
|
||||
class ManuallyTask extends AbstractTask {
|
||||
class ManuallyTask extends AbstractTask
|
||||
{
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
@@ -50,12 +51,10 @@ class ManuallyTask extends AbstractTask {
|
||||
|
||||
$commands = $this->getParameters();
|
||||
|
||||
foreach ($commands as $command)
|
||||
{
|
||||
foreach ($commands as $command) {
|
||||
$result = $result && $this->runCommand($command);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ class EncryptTask extends AbstractTask
|
||||
* Check if we have been given an encoder script
|
||||
* If not then we will just use the default
|
||||
*/
|
||||
if (isset ($this->mageConfig ['encoder'])) {
|
||||
if (isset($this->mageConfig ['encoder'])) {
|
||||
$this->encoder = $this->mageConfig ['encoder'];
|
||||
}
|
||||
/*
|
||||
@@ -233,14 +233,14 @@ class EncryptTask extends AbstractTask
|
||||
* supplied, this defines how the 3 differant
|
||||
* config files will be merged together.
|
||||
*/
|
||||
if (isset ($this->mageConfig ['override'])) {
|
||||
if (isset($this->mageConfig ['override'])) {
|
||||
$this->ionOverRide = $this->mageConfig ['override'];
|
||||
}
|
||||
/*
|
||||
* Check if we have been asked to
|
||||
* confirm all encodings
|
||||
*/
|
||||
if (isset ($this->mageConfig ['checkencoding'])) {
|
||||
if (isset($this->mageConfig ['checkencoding'])) {
|
||||
$this->checkEncoding = true;
|
||||
}
|
||||
/*
|
||||
@@ -249,7 +249,7 @@ class EncryptTask extends AbstractTask
|
||||
* encrypt/encode file check
|
||||
*
|
||||
*/
|
||||
if (isset ($this->mageConfig ['checkignoreextens'])) {
|
||||
if (isset($this->mageConfig ['checkignoreextens'])) {
|
||||
$this->checkIgnoreExtens = array_merge($this->ignoreExtens, $this->mageConfig['ignoreextens']);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ class EncryptTask extends AbstractTask
|
||||
* encrypt/encode file check
|
||||
*
|
||||
*/
|
||||
if (isset ($this->mageConfig ['checkignorepaths'])) {
|
||||
if (isset($this->mageConfig ['checkignorepaths'])) {
|
||||
$this->checkIgnorePaths = array_merge($this->checkIgnorePaths, $this->mageConfig['checkignorepaths']);
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ class EncryptTask extends AbstractTask
|
||||
* Check if there is a 'project' section,
|
||||
* if so then get the options from there
|
||||
*/
|
||||
if (isset ($this->mageConfig ['project'])) {
|
||||
if (isset($this->mageConfig ['project'])) {
|
||||
$this->yaml = $this->getOptionsFromYaml($this->mageConfig ['project']);
|
||||
} else {
|
||||
$this->yaml = array(
|
||||
@@ -301,7 +301,7 @@ class EncryptTask extends AbstractTask
|
||||
* Check if a seperate projectfile has been specified, and if so
|
||||
* then read the options from there.
|
||||
*/
|
||||
if (isset ($this->mageConfig ['projectfile'])) {
|
||||
if (isset($this->mageConfig ['projectfile'])) {
|
||||
$this->file = $this->getOptionsFromFile($this->mageConfig ['projectfile']);
|
||||
} else {
|
||||
$this->file = array(
|
||||
@@ -359,8 +359,8 @@ class EncryptTask extends AbstractTask
|
||||
// $ask holds flag to indicate we need to prompt the end user
|
||||
$ask = false;
|
||||
// scan through the directory
|
||||
$rit = new \RecursiveDirectoryIterator ($src);
|
||||
foreach (new \RecursiveIteratorIterator ($rit) as $filename => $cur) {
|
||||
$rit = new \RecursiveDirectoryIterator($src);
|
||||
foreach (new \RecursiveIteratorIterator($rit) as $filename => $cur) {
|
||||
// get the 'base dir' for the project, eg. relative to the temp folder
|
||||
$srcFileName = (str_replace($this->source, '', $filename));
|
||||
/*
|
||||
@@ -468,7 +468,7 @@ class EncryptTask extends AbstractTask
|
||||
*/
|
||||
private function deleteTmpFiles()
|
||||
{
|
||||
if (isset ($this->mageConfig ['keeptemp'])) {
|
||||
if (isset($this->mageConfig ['keeptemp'])) {
|
||||
return;
|
||||
}
|
||||
Console::log('Deleting tempory files :', 1);
|
||||
@@ -477,7 +477,7 @@ class EncryptTask extends AbstractTask
|
||||
if ($ret1 && $ret2) {
|
||||
return;
|
||||
}
|
||||
throw new ErrorWithMessageException ('Error deleting temp files :' . $out1 . ' : ' . $out2, 40);
|
||||
throw new ErrorWithMessageException('Error deleting temp files :' . $out1 . ' : ' . $out2, 40);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,7 +533,7 @@ class EncryptTask extends AbstractTask
|
||||
if (!$ret) {
|
||||
// something went wrong
|
||||
$this->deleteTmpFiles();
|
||||
throw new ErrorWithMessageException ('Unable to create project file.', 20);
|
||||
throw new ErrorWithMessageException('Unable to create project file.', 20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,11 +603,11 @@ class EncryptTask extends AbstractTask
|
||||
{
|
||||
$ret = Console::executeCommand('mv ' . $this->source . ' ' . $this->ionSource, $out);
|
||||
if (!$ret) {
|
||||
throw new ErrorWithMessageException ('Cant create tmp dir :' . $out, $ret);
|
||||
throw new ErrorWithMessageException('Cant create tmp dir :' . $out, $ret);
|
||||
}
|
||||
$ret = Console::executeCommand('mkdir -p ' . $this->source, $out);
|
||||
if (!$ret) {
|
||||
throw new ErrorWithMessageException ('Cant re-create dir :' . $out, $ret);
|
||||
throw new ErrorWithMessageException('Cant re-create dir :' . $out, $ret);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Mage\Task\BuiltIn\Releases;
|
||||
use Mage\Console;
|
||||
use Mage\Task\AbstractTask;
|
||||
use Mage\Task\Releases\IsReleaseAware;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
@@ -87,7 +86,6 @@ class ListTask extends AbstractTask implements IsReleaseAware
|
||||
|
||||
Console::output('');
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
Console::output('');
|
||||
return false;
|
||||
@@ -109,32 +107,28 @@ class ListTask extends AbstractTask implements IsReleaseAware
|
||||
if ($diff->format('%a') <= 7) {
|
||||
if ($diff->format('%d') == 7) {
|
||||
$textDiff = ' [a week ago] ';
|
||||
|
||||
} else if ($diff->format('%d') > 0 && $diff->format('%d') < 7) {
|
||||
} elseif ($diff->format('%d') > 0 && $diff->format('%d') < 7) {
|
||||
$days = $diff->format('%d');
|
||||
if ($days <= 1) {
|
||||
$textDiff = ' [one day ago] ';
|
||||
} else {
|
||||
$textDiff = ' [' . $days . ' days ago] ';
|
||||
}
|
||||
|
||||
} else if ($diff->format('%d') == 0 && $diff->format('%h') > 0) {
|
||||
} elseif ($diff->format('%d') == 0 && $diff->format('%h') > 0) {
|
||||
$hours = $diff->format('%h');
|
||||
if ($hours <= 1) {
|
||||
$textDiff = ' [one hour ago] ';
|
||||
} else {
|
||||
$textDiff = ' [' . $hours . ' hours ago] ';
|
||||
}
|
||||
|
||||
} else if ($diff->format('%d') == 0 && $diff->format('%h') == 0) {
|
||||
} elseif ($diff->format('%d') == 0 && $diff->format('%h') == 0) {
|
||||
$minutes = $diff->format('%i');
|
||||
if ($minutes <= 1) {
|
||||
$textDiff = ' [one minute ago] ';
|
||||
} else {
|
||||
$textDiff = ' [' . $minutes . ' minutes ago] ';
|
||||
}
|
||||
|
||||
} else if ($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');
|
||||
if ($seconds < 10) {
|
||||
$textDiff = ' [just now!] ';
|
||||
|
||||
@@ -61,12 +61,11 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
|
||||
|
||||
if (count($releases) == 0) {
|
||||
Console::output('Release are not available for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>');
|
||||
|
||||
} else {
|
||||
rsort($releases);
|
||||
$deleteCurrent = $this->getConfig()->getParameter('deleteCurrent',
|
||||
$this->getConfig()->deployment('delete-on-rollback',
|
||||
$this->getConfig()->general('delete-on-rollback',false)
|
||||
$this->getConfig()->general('delete-on-rollback', false)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -74,8 +73,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
|
||||
if ($this->getReleaseId() == '') {
|
||||
$releaseId = $releases[0];
|
||||
$releaseIsAvailable = true;
|
||||
|
||||
} else if ($this->getReleaseId() <= 0) {
|
||||
} elseif ($this->getReleaseId() <= 0) {
|
||||
$index = $this->getReleaseId() * -1;
|
||||
if (isset($releases[$index])) {
|
||||
$releaseId = $releases[$index];
|
||||
@@ -92,7 +90,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
|
||||
|
||||
if (!$releaseIsAvailable) {
|
||||
Console::output('Release <bold>' . $this->getReleaseId() . '</bold> is invalid or unavailable for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>');
|
||||
|
||||
} else {
|
||||
Console::output('Rollback release on <bold>' . $this->getConfig()->getHost() . '</bold>');
|
||||
$rollbackTo = $releasesDirectory . '/' . $releaseId;
|
||||
@@ -116,7 +113,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
|
||||
$task->init();
|
||||
Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false);
|
||||
|
||||
if ($task instanceOf RollbackAware) {
|
||||
if ($task instanceof RollbackAware) {
|
||||
/* @var $task AbstractTask */
|
||||
$tasks++;
|
||||
$result = $task->run();
|
||||
@@ -166,7 +163,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
|
||||
$task->init();
|
||||
Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false);
|
||||
|
||||
if ($task instanceOf RollbackAware) {
|
||||
if ($task instanceof RollbackAware) {
|
||||
/* @var $task AbstractTask */
|
||||
$tasks++;
|
||||
$result = $task->run();
|
||||
@@ -193,7 +190,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,6 @@ class ChangeBranchTask extends AbstractTask
|
||||
if ($this->getParameter('_changeBranchRevert', false)) {
|
||||
$command = $preCommand . 'git checkout ' . self::$startingBranch;
|
||||
$result = $this->runCommandLocal($command);
|
||||
|
||||
} else {
|
||||
$command = $preCommand . 'git branch | grep \'*\' | cut -d\' \' -f 2';
|
||||
$currentBranch = 'master';
|
||||
|
||||
@@ -15,9 +15,9 @@ use Mage\Task\SkipException;
|
||||
|
||||
/**
|
||||
* Task for Force Updating a Working Copy
|
||||
*
|
||||
*
|
||||
* 'git fetch' downloads the latest from remote without trying to merge or rebase anything.
|
||||
* 'git reset' resets the master branch to what you just fetched.
|
||||
* 'git reset' resets the master branch to what you just fetched.
|
||||
* The '--hard' option changes all the files in your working tree to match the files in origin/master,
|
||||
* so if you have any local changes, they will be lost.
|
||||
*
|
||||
|
||||
@@ -54,7 +54,7 @@ class UpdateTask extends AbstractTask
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$command = 'cd ' . $this->getConfig()->deployment('from', './') . '; ';
|
||||
$command = 'cd ' . $this->getConfig()->deployment('from', './') . '; ';
|
||||
switch ($this->getConfig()->general('scm')) {
|
||||
case 'git':
|
||||
$command .= 'git pull';
|
||||
|
||||
@@ -14,7 +14,7 @@ use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask;
|
||||
|
||||
/**
|
||||
* Task for Clearing the Cache
|
||||
*
|
||||
*
|
||||
* Example of usage:
|
||||
* symfony2/cache-clear: { env: dev }
|
||||
* symfony2/cache-clear: { env: dev, optional: --no-warmup }
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Mage\Task;
|
||||
|
||||
use Mage\Config;
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@@ -48,7 +47,6 @@ class Factory
|
||||
|
||||
if (strpos($taskName, '/') === false) {
|
||||
$className = 'Task\\' . $taskName;
|
||||
|
||||
} else {
|
||||
$className = 'Mage\\Task\\BuiltIn\\' . str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))) . 'Task';
|
||||
}
|
||||
|
||||
@@ -19,5 +19,4 @@ use Exception;
|
||||
*/
|
||||
class RollbackException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user