From 1dfbddecc8b25f4884ea694ecdaed23f016ed57a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 17 Aug 2022 18:08:01 +0200 Subject: [PATCH] wip #5400 @0.5 --- src/CommandLine/Git.php | 52 ++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/src/CommandLine/Git.php b/src/CommandLine/Git.php index cbf2b49..9eb3f9c 100644 --- a/src/CommandLine/Git.php +++ b/src/CommandLine/Git.php @@ -1,20 +1,46 @@ _repos = $repos; + $this->cd($repos); + } - public function __construct($repos, $output = null, $error = true) { - parent::__construct('git', $output, $error); - $this->_repos = $repos; - $this->cd($repos); - } + public function executeCmd($cmd) + { + $this->setManualArg($cmd); + $this->execute(); + return $this->getOutput(); + } - public function executeCmd($cmd) { - $this->setManualArg($cmd); - $this->execute(); - return $cmd . ' :: ' . file_get_contents($this->output); - } -} \ No newline at end of file + public function listBranches() + { + $b = $this->executeCmd('branch -r'); + $bb = explode("\n", $b); + $branches = array(); + foreach ($bb as $item) { + $item = trim($item); + if ($item == '') { + continue; + } + $e = explode('->', $item); + if (count($e) == 2) { + $item = $e[1]; + } else { + $item = $e[0]; + } + $e = explode("/", $item); + $branches[trim($e[1])] = true; + } + return array_keys($branches); + } +} -- 2.39.5