Change SCM configs.

This commit is contained in:
Andrés Montañez
2013-07-06 20:46:19 -03:00
parent 6015b6d7c1
commit 39b1bf7cd5
6 changed files with 38 additions and 99 deletions
+23 -16
View File
@@ -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,29 +25,35 @@ class Mage_Task_BuiltIn_Scm_ChangeBranch
public function run()
{
switch ($this->getConfig()->scm('type')) {
switch ($this->getConfig()->general('scm')) {
case 'git':
$command = 'git branch | grep \'*\' | cut -d\' \' -f 2';
$currentBranch = 'master';
$result = $this->_runLocalCommand($command, $currentBranch);
if ($this->getParameter('_changeBranchRevert', false)) {
$command = 'git checkout ' . self::$_startingBranch;
$result = $this->_runLocalCommand($command);
$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);
} else {
$command = 'git branch | grep \'*\' | cut -d\' \' -f 2';
$currentBranch = 'master';
$result = $this->_runLocalCommand($command, $currentBranch);
$oldBranchFile = '.mage/' . $this->getConfig()->getEnvironment() . '.oldBranch';
file_put_contents($oldBranchFile, $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;
} else {
throw new Mage_Task_SkipException;
}
}
} 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;
}
}
+1 -1
View File
@@ -43,7 +43,7 @@ class Mage_Task_BuiltIn_Scm_Clone
break;
case 'svn':
return false;
throw new Mage_Task_SkipException;
break;
}
+2 -2
View File
@@ -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;
}