|
<?php |
|
|
|
/** |
|
* This is project's console commands configuration for Robo task runner. |
|
* |
|
* @see http://robo.li/ |
|
*/ |
|
class RoboFile extends \Robo\Tasks |
|
{ |
|
/** |
|
* @var string |
|
*/ |
|
private $dirPrefix = 'dev'; |
|
|
|
/** |
|
* @var string |
|
*/ |
|
private $upstreamPrefix = '[email protected]:activecampaign/'; |
|
|
|
/** |
|
* @var string |
|
*/ |
|
private $originPrefix = '[email protected]:bangpound/'; |
|
|
|
/** |
|
* @var array |
|
*/ |
|
private $allRepos = ['Hosted-Scripts', 'cdn', 'ember-app', 'Hosted', 'library', 'provision']; |
|
|
|
/** |
|
* @var array |
|
*/ |
|
private $versionedRepos = ['ember-app', 'Hosted']; |
|
|
|
// add method for switching to [email protected] |
|
// add method for running nombom |
|
|
|
/** |
|
* Pull all repositories. |
|
*/ |
|
public function gitUp() |
|
{ |
|
foreach ($this->allRepos as $repo) { |
|
$this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->pull()->run(); |
|
} |
|
} |
|
|
|
/** |
|
* Switch ember-app and Hosted repositories to specified branch. |
|
*/ |
|
public function gitSwitch($branch = 'version-8.3') |
|
{ |
|
foreach ($this->versionedRepos as $repo) { |
|
$this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->checkout($branch)->run(); |
|
} |
|
} |
|
|
|
/** |
|
* Clone all repositories and set ActiveCampaign as upstream remote. |
|
*/ |
|
public function gitClone() |
|
{ |
|
foreach ($this->allRepos as $repo) { |
|
$this->taskGitStack()->cloneRepo($this->originPrefix . $repo . '.git', $this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->run(); |
|
$this->taskExec('git')->args(['remote', 'add', 'upstream', $this->upstreamPrefix . $repo . '.git'])->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->run(); |
|
} |
|
} |
|
|
|
/** |
|
* Fetch from all repositories. |
|
*/ |
|
public function gitFetch() |
|
{ |
|
foreach ($this->allRepos as $repo) { |
|
$this->io()->title($repo); |
|
$this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->exec(['fetch', '--all'])->printOutput(false)->run(); |
|
} |
|
} |
|
|
|
/** |
|
* Rebase checked out branches on upstream and push to origin. |
|
*/ |
|
public function gitRebase() |
|
{ |
|
foreach ($this->allRepos as $repo) { |
|
$this->io()->title($repo); |
|
$this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->exec(['fetch', '--all'])->printOutput(false)->run(); |
|
/** @var \Robo\Result $result */ |
|
$result = $this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->exec(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])->printOutput(false)->run(); |
|
$branch = $result->getOutputData(); |
|
$this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->exec(['rebase', '--autostash', 'upstream/'. $branch])->printOutput(false)->run(); |
|
$this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->push('origin')->printOutput(false)->run(); |
|
} |
|
} |
|
|
|
public function gitUpdate() |
|
{ |
|
foreach ($this->allRepos as $repo) { |
|
$this->taskGitStack()->exec($this->originPrefix . $repo . '.git', $this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->run(); |
|
$this->taskExec('git')->args(['remote', 'add', 'upstream', $this->upstreamPrefix . $repo . '.git'])->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->run(); |
|
} |
|
} |
|
|
|
/** |
|
* Show status of all repositories. |
|
*/ |
|
public function gitStatus() |
|
{ |
|
$table = new \Symfony\Component\Console\Helper\Table($this->output); |
|
$table->setHeaders(['Repo', 'Branch']); |
|
foreach ($this->allRepos as $repo) { |
|
$result = $this->taskGitStack()->dir($this->dirPrefix . DIRECTORY_SEPARATOR . $repo)->exec(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])->run(); |
|
$branch = trim($result->getOutputData()); |
|
$table->addRow([$repo, $branch]); |
|
} |
|
$table->render(); |
|
} |
|
} |