Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2a9bf0
commit ca12e74
Showing
4 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
<?php | |||
class Mage_Task_BuiltIn_Scm_ChangeBranch | |||
extends Mage_Task_TaskAbstract | |||
{ | |||
private $_name = 'SCM Changing branch [built-in]'; | |||
|
|||
public function getName() | |||
{ | |||
return $this->_name; | |||
} | |||
|
|||
public function init() | |||
{ | |||
switch ($this->getConfig()->scm('type')) { | |||
case 'git': | |||
$this->_name = 'SCM Changing branch (GIT) [built-in]'; | |||
break; | |||
|
|||
case 'svn': | |||
$this->_name = 'SCM Changing branch (Subversion) [built-in]'; | |||
break; | |||
} | |||
} | |||
|
|||
public function run() | |||
{ | |||
switch ($this->getConfig()->scm('type')) { | |||
case 'git': | |||
$command = 'git branch | grep \'*\' | cut -d\' \' -f 2'; | |||
$currentBranch = 'master'; | |||
$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); | |||
|
|||
$oldBranchFile = '.mage/' . $this->getConfig()->getEnvironment() . '.oldBranch'; | |||
file_put_contents($oldBranchFile, $currentBranch); | |||
|
|||
} else { | |||
throw new Mage_Task_SkipException; | |||
} | |||
|
|||
break; | |||
|
|||
default: | |||
return false; | |||
break; | |||
} | |||
|
|||
|
|||
$this->getConfig()->reload(); | |||
|
|||
return $result; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
<?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; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters