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(); } }