mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-16 12:35:04 +02:00
Allow to fail a task with a message via Mage_Task_ErrorWithMessageException
This commit is contained in:
parent
d5ebf6e6e3
commit
fe60dfbdd4
|
@ -305,6 +305,10 @@ class Mage_Command_BuiltIn_Deploy
|
|||
Mage_Console::output('<red>FAIL</red>', 0);
|
||||
$result = false;
|
||||
}
|
||||
} catch (Mage_Task_ErrorWithMessageException $e) {
|
||||
Mage_Console::output('<red>FAIL</red> [Message: ' . $e->getMessage() . ']', 0);
|
||||
$result = false;
|
||||
|
||||
} catch (Mage_Task_SkipException $e) {
|
||||
Mage_Console::output('<yellow>SKIPPED</yellow>', 0);
|
||||
$result = true;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
class Mage_Task_BuiltIn_Scm_ChangeBranch
|
||||
extends Mage_Task_TaskAbstract
|
||||
{
|
||||
protected static $_startingBranch = 'master';
|
||||
protected static $startingBranch = 'master';
|
||||
private $_name = 'SCM Changing branch [built-in]';
|
||||
|
||||
public function getName()
|
||||
|
@ -25,10 +25,11 @@ class Mage_Task_BuiltIn_Scm_ChangeBranch
|
|||
|
||||
public function run()
|
||||
{
|
||||
switch ($this->getConfig()->general('scm')) {
|
||||
$scmConfig = $this->getConfig()->general('scm', array());
|
||||
switch ((isset($scmConfig['type']) ? $scmConfig['type'] : false)) {
|
||||
case 'git':
|
||||
if ($this->getParameter('_changeBranchRevert', false)) {
|
||||
$command = 'git checkout ' . self::$_startingBranch;
|
||||
$command = 'git checkout ' . self::$startingBranch;
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
} else {
|
||||
|
@ -37,19 +38,25 @@ class Mage_Task_BuiltIn_Scm_ChangeBranch
|
|||
$result = $this->_runLocalCommand($command, $currentBranch);
|
||||
|
||||
$scmData = $this->getConfig()->deployment('scm', false);
|
||||
if ($result && is_array($scmData) && isset($scmData['branch'])) {
|
||||
$branch = $this->getParameter('branch', $scmData['branch']);
|
||||
$command = 'git checkout ' . $branch;
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
self::$_startingBranch = $currentBranch;
|
||||
if ($result && is_array($scmData) && isset($scmData['branch']) && $scmData['branch'] != $currentBranch) {
|
||||
$command = 'git branch | grep \'' . $scmData['branch'] . '\' | tr -s \' \' | sed \'s/^[ ]//g\'';
|
||||
$isBranchTracked = '';
|
||||
$result = $this->_runLocalCommand($command, $isBranchTracked);
|
||||
|
||||
if ($isBranchTracked == '') {
|
||||
throw new Mage_Task_ErrorWithMessageException('The branch <purple>' . $scmData['branch'] . '</purple> must be tracked.');
|
||||
}
|
||||
|
||||
$branch = $this->getParameter('branch', $scmData['branch']);
|
||||
$command = 'git checkout ' . $branch;
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
self::$startingBranch = $currentBranch;
|
||||
} else {
|
||||
throw new Mage_Task_SkipException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
6
Mage/Task/ErrorWithMessageException.php
Normal file
6
Mage/Task/ErrorWithMessageException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
class Mage_Task_ErrorWithMessageException
|
||||
extends Exception
|
||||
{
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ deployment:
|
|||
from: ./
|
||||
to: /var/www/
|
||||
scm:
|
||||
branch: master
|
||||
branch: master2
|
||||
releases:
|
||||
enabled: true
|
||||
max: 5
|
||||
|
|
Loading…
Reference in a new issue