function GitDriver::getBranches
@inheritDoc
Overrides VcsDriverInterface::getBranches
1 call to GitDriver::getBranches()
- GitDriver::initialize in vendor/
composer/ composer/ src/ Composer/ Repository/ Vcs/ GitDriver.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ Repository/ Vcs/ GitDriver.php, line 194
Class
- GitDriver
- @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\Repository\VcsCode
public function getBranches() : array {
if (null === $this->branches) {
$branches = [];
$this->process
->execute([
'git',
'branch',
'--no-color',
'--no-abbrev',
'-v',
], $output, $this->repoDir);
foreach ($this->process
->splitLines($output) as $branch) {
if ($branch !== '' && !Preg::isMatch('{^ *[^/]+/HEAD }', $branch)) {
if (Preg::isMatchStrictGroups('{^(?:\\* )? *(\\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match) && $match[1][0] !== '-') {
$branches[$match[1]] = $match[2];
}
}
}
$this->branches = $branches;
}
return $this->branches;
}