X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/ba158e3ed03dec10e6654b0b0dd3710504bdf04d..2a665e0f4eeb45c9d57df7dc7f9d853465b5fea9:/src/phorkie/Repository/ConnectionInfo.php diff --git a/src/phorkie/Repository/ConnectionInfo.php b/src/phorkie/Repository/ConnectionInfo.php index 3815856..f6a7a40 100644 --- a/src/phorkie/Repository/ConnectionInfo.php +++ b/src/phorkie/Repository/ConnectionInfo.php @@ -10,7 +10,10 @@ class Repository_ConnectionInfo public function __construct(Repository $repo) { $this->repo = $repo; - $this->arConfig = parse_ini_file($this->repo->gitDir . '/config', true); + //we need raw parsing; https://bugs.php.net/bug.php?id=68347 + $this->arConfig = parse_ini_file( + $this->repo->gitDir . '/config', true, INI_SCANNER_RAW + ); } public function isFork() @@ -18,6 +21,11 @@ class Repository_ConnectionInfo return $this->getOrigin() !== null; } + public function hasForks() + { + return count($this->getForks()) > 0; + } + public function getOrigin() { @@ -30,13 +38,24 @@ class Repository_ConnectionInfo */ public function getRemote($name) { - if (!isset($this->arConfig['remote ' . $name])) { + if (!isset($this->arConfig['remote "' . $name . '"'])) { return null; } - return new Repository_Remote($name, $this->arConfig['remote ' . $name]); + return new Repository_Remote($name, $this->arConfig['remote "' . $name . '"']); } + public function getForks() + { + $arForks = array(); + foreach ($this->arConfig as $name => $data) { + if (substr($name, 0, 13) != 'remote "fork-') { + continue; + } + $arForks[substr($name, 8, -1)] = new Repository_Remote( + substr($name, 8, -1), $data + ); + } + return $arForks; + } } - - ?>