/** * Fetches the branches via the `git branch` command. * * @param boolean $only_remote * Whether to fetch only remote branches, defaults to false which returns * all branches. * * @return array */ public function fetchLocalBranches() { $this->git->clearOutput(); $output = (string) $this->git->branch(); $branches = preg_split("/\r\n|\n|\r/", rtrim($output)); return array_map(array($this, 'trimBranch'), $branches); }
/** * Constructs a GitBranches object. * * @param \GitWrapper\GitWorkingCopy $git * The working copy that branches are being collected from. * * @throws \GitWrapper\GitException */ public function __construct(GitWorkingCopy $git) { $this->git = clone $git; $output = (string) $git->branch(array('a' => true)); }