function Perforce::getBranches
Return value
array{master: string}
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Perforce.php, line 500
Class
- Perforce
- @author Matt Whittom <Matt.Whittom@veteransunited.com>
Namespace
Composer\UtilCode
public function getBranches() : array {
$possibleBranches = [];
if (!$this->isStream()) {
$possibleBranches[$this->p4Branch] = $this->getStream();
}
else {
$command = $this->generateP4Command('streams ' . ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
$this->executeCommand($command);
$result = $this->commandResult;
$resArray = explode(PHP_EOL, $result);
foreach ($resArray as $line) {
$resBits = explode(' ', $line);
if (count($resBits) > 4) {
$branch = Preg::replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
$possibleBranches[$branch] = $resBits[1];
}
}
}
$command = $this->generateP4Command('changes ' . ProcessExecutor::escape($this->getStream() . '/...'), false);
$this->executeCommand($command);
$result = $this->commandResult;
$resArray = explode(PHP_EOL, $result);
$lastCommit = $resArray[0];
$lastCommitArr = explode(' ', $lastCommit);
$lastCommitNum = $lastCommitArr[1];
return [
'master' => $possibleBranches[$this->p4Branch] . '@' . $lastCommitNum,
];
}