mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-26 17:20:13 +02:00
Change SCM configs.
This commit is contained in:
parent
6015b6d7c1
commit
39b1bf7cd5
|
@ -167,7 +167,8 @@ class Mage_Command_BuiltIn_Deploy
|
|||
if ($stage == 'post-deploy') {
|
||||
// Change Branch Back
|
||||
if ($this->getConfig()->deployment('scm', false)) {
|
||||
array_unshift($tasksToRun, 'scm/change-branch-back');
|
||||
array_unshift($tasksToRun, 'scm/change-branch');
|
||||
$config->addParameter('_changeBranchRevert');
|
||||
}
|
||||
|
||||
// Remove Remote Source
|
||||
|
|
|
@ -8,7 +8,6 @@ class Mage_Config
|
|||
private $_releaseId = null;
|
||||
private $_config = array(
|
||||
'general' => array(),
|
||||
'scm' => array(),
|
||||
'environment' => array(),
|
||||
);
|
||||
|
||||
|
@ -78,6 +77,16 @@ class Mage_Config
|
|||
return $this->_parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds (or replaces) a parameter
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function addParameter($name, $value = true)
|
||||
{
|
||||
$this->_parameters[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Current environment
|
||||
*
|
||||
|
@ -218,27 +227,6 @@ class Mage_Config
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets SCM Configuration
|
||||
*
|
||||
* @param string $option
|
||||
* @param string $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function scm($option, $default = false)
|
||||
{
|
||||
$config = $this->_config['scm'];
|
||||
if (isset($config[$option])) {
|
||||
if (is_array($default) && ($config[$option] == '')) {
|
||||
return $default;
|
||||
} else {
|
||||
return $config[$option];
|
||||
}
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deployment configuration
|
||||
*
|
||||
|
@ -354,16 +342,6 @@ class Mage_Config
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the SCM Configuration
|
||||
*/
|
||||
private function _loadSCM()
|
||||
{
|
||||
if (file_exists('.mage/config/scm.yml')) {
|
||||
$this->_config['scm'] = spyc_load_file('.mage/config/scm.yml');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the Environment configuration
|
||||
*
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
class Mage_Task_BuiltIn_Scm_ChangeBranch
|
||||
extends Mage_Task_TaskAbstract
|
||||
{
|
||||
protected static $_startingBranch = 'master';
|
||||
private $_name = 'SCM Changing branch [built-in]';
|
||||
|
||||
public function getName()
|
||||
|
@ -11,7 +12,7 @@ class Mage_Task_BuiltIn_Scm_ChangeBranch
|
|||
|
||||
public function init()
|
||||
{
|
||||
switch ($this->getConfig()->scm('type')) {
|
||||
switch ($this->getConfig()->general('scm')) {
|
||||
case 'git':
|
||||
$this->_name = 'SCM Changing branch (GIT) [built-in]';
|
||||
break;
|
||||
|
@ -24,8 +25,13 @@ class Mage_Task_BuiltIn_Scm_ChangeBranch
|
|||
|
||||
public function run()
|
||||
{
|
||||
switch ($this->getConfig()->scm('type')) {
|
||||
switch ($this->getConfig()->general('scm')) {
|
||||
case 'git':
|
||||
if ($this->getParameter('_changeBranchRevert', false)) {
|
||||
$command = 'git checkout ' . self::$_startingBranch;
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
} else {
|
||||
$command = 'git branch | grep \'*\' | cut -d\' \' -f 2';
|
||||
$currentBranch = 'master';
|
||||
$result = $this->_runLocalCommand($command, $currentBranch);
|
||||
|
@ -36,17 +42,18 @@ class Mage_Task_BuiltIn_Scm_ChangeBranch
|
|||
$command = 'git checkout ' . $branch;
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
$oldBranchFile = '.mage/' . $this->getConfig()->getEnvironment() . '.oldBranch';
|
||||
file_put_contents($oldBranchFile, $currentBranch);
|
||||
self::$_startingBranch = $currentBranch;
|
||||
|
||||
} else {
|
||||
throw new Mage_Task_SkipException;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
throw new Mage_Task_SkipException;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
class Mage_Task_BuiltIn_Scm_ChangeBranchBack
|
||||
extends Mage_Task_TaskAbstract
|
||||
{
|
||||
private $_name = 'SCM Changing branch Back [built-in]';
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
switch ($this->getConfig()->scm('type')) {
|
||||
case 'git':
|
||||
$this->_name = 'SCM Changing branch Back (GIT) [built-in]';
|
||||
break;
|
||||
|
||||
case 'svn':
|
||||
$this->_name = 'SCM Changing branch Back (Subversion) [built-in]';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
switch ($this->getConfig()->scm('type')) {
|
||||
case 'git':
|
||||
$oldBranchFile = '.mage/' . $this->getConfig()->getEnvironment() . '.oldBranch';
|
||||
$currentBranch = trim(file_get_contents($oldBranchFile));
|
||||
|
||||
$command = 'git checkout ' . $currentBranch;
|
||||
$result = $this->_runLocalCommand($command);
|
||||
@unlink($oldBranchFile);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$this->getConfig()->reload();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ class Mage_Task_BuiltIn_Scm_Clone
|
|||
break;
|
||||
|
||||
case 'svn':
|
||||
return false;
|
||||
throw new Mage_Task_SkipException;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class Mage_Task_BuiltIn_Scm_Update
|
|||
|
||||
public function init()
|
||||
{
|
||||
switch ($this->getConfig()->scm('type')) {
|
||||
switch ($this->getConfig()->general('scm')) {
|
||||
case 'git':
|
||||
$this->_name = 'SCM Update (GIT) [built-in]';
|
||||
break;
|
||||
|
@ -34,7 +34,7 @@ class Mage_Task_BuiltIn_Scm_Update
|
|||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
throw new Mage_Task_SkipException;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue