Merge pull request #158 from samuel4x4/develop

Bug fix for scm/force-update, add general/manually task, bug fix for symfony2/doctrine-migrate, improve symfony2/cache-clear
This commit is contained in:
Andrés Montañez 2014-12-01 21:33:21 -02:00
commit ba9b322dab
4 changed files with 75 additions and 6 deletions

View file

@ -0,0 +1,61 @@
<?php
/*
* This file is part of the Magallanes package.
*
* (c) Andrés Montañez <andres@andresmontanez.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mage\Task\BuiltIn\General;
use Mage\Task\AbstractTask;
/**
* Task for running multiple custom commands setting them manually
*
* Example of usage:
*
* tasks:
* on-deploy:
* - scm/force-update
* - general/manually:
* - find . -type d -exec chmod 755 {} \;
* - find . -type f -exec chmod 644 {} \;
* - chmod +x bin/console
* - find var/logs -maxdepth 1 -type f -name '*.log' -exec chown apache:apache {} \;
* - symfony2/cache-clear
*
* @author Samuel Chiriluta <samuel4x4@gmail.com>
*/
class ManuallyTask extends AbstractTask {
/**
* (non-PHPdoc)
* @see \Mage\Task\AbstractTask::getName()
*/
public function getName()
{
return 'Manually multiple custom tasks';
}
/**
* @see \Mage\Task\AbstractTask::run()
*/
public function run()
{
$result = true;
$commands = $this->getParameters();
foreach ($commands as $command)
{
$result = $result && $this->runCommand($command);
}
return $result;
}
}

View file

@ -65,13 +65,13 @@ class ForceUpdateTask extends AbstractTask
$remote = $this->getParameter('remote', 'origin');
$command = 'git fetch ' . $remote . ' ' . $branch;
$result = $this->runCommandRemote($command);
$result = $this->runCommand($command);
$command = 'git reset --hard ' . $remote . '/' . $branch;
$result = $result && $this->runCommandRemote($command);
$result = $result && $this->runCommand($command);
$command = 'git pull ' . $remote . ' ' . $branch;
$result = $result && $this->runCommandRemote($command);
$result = $result && $this->runCommand($command);
break;
default:
@ -79,7 +79,6 @@ class ForceUpdateTask extends AbstractTask
break;
}
$result = $this->runCommandLocal($command);
$this->getConfig()->reload();
return $result;

View file

@ -14,8 +14,13 @@ 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 }
*
* @author Andrés Montañez <andres@andresmontanez.com>
* @author Samuel Chiriluta <samuel4x4@gmail.com>
*/
class CacheClearTask extends SymfonyAbstractTask
{
@ -36,8 +41,10 @@ class CacheClearTask extends SymfonyAbstractTask
{
// Options
$env = $this->getParameter('env', 'dev');
$optional = $this->getParameter('optional', '');
$command = $this->getAppPath() . ' cache:clear --env=' . $env . ' ' . $optional;
$command = $this->getAppPath() . ' cache:clear --env=' . $env;
$result = $this->runCommand($command);
return $result;

View file

@ -15,7 +15,7 @@ use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask;
/**
* Task for Doctrine migrations
*/
class DoctrineMigrate extends SymfonyAbstractTask
class DoctrineMigrateTask extends SymfonyAbstractTask
{
/**
* (non-PHPdoc)
@ -34,7 +34,9 @@ class DoctrineMigrate extends SymfonyAbstractTask
public function run()
{
$env = $this->getParameter('env', 'dev');
$command = $this->getAppPath() . ' doctrine:migrations:migrate -n --env=' . $env;
return $this->runCommand($command);
}
}