Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistGitAPI.php
| Show First 20 Lines • Show All 960 Lines • ▼ Show 20 Lines | final class ArcanistGitAPI extends ArcanistRepositoryAPI { | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns names of all the branches in the current repository. | * Returns names of all the branches in the current repository. | ||||
| * | * | ||||
| * @return list<dict<string, string>> Dictionary of branch information. | * @return list<dict<string, string>> Dictionary of branch information. | ||||
| */ | */ | ||||
| public function getAllBranches() { | public function getAllBranches() { | ||||
| list($ref_list) = $this->execxLocal( | $field_list = array( | ||||
| 'for-each-ref --format=%s refs/heads', | '%(refname)', | ||||
| '%(refname)'); | '%(objectname)', | ||||
| $refs = explode("\n", rtrim($ref_list)); | '%(committerdate:raw)', | ||||
| '%(tree)', | |||||
| '%(subject)', | |||||
| '%(subject)%0a%0a%(body)', | |||||
| '%02', | |||||
| ); | |||||
| list($stdout) = $this->execxLocal( | |||||
| 'for-each-ref --format=%s -- refs/heads', | |||||
| implode('%01', $field_list)); | |||||
| $current = $this->getBranchName(); | $current = $this->getBranchName(); | ||||
| $result = array(); | $result = array(); | ||||
| foreach ($refs as $ref) { | |||||
| $lines = explode("\2", $stdout); | |||||
| foreach ($lines as $line) { | |||||
| $line = trim($line); | |||||
| if (!strlen($line)) { | |||||
| continue; | |||||
| } | |||||
| $fields = explode("\1", $line, 6); | |||||
| list($ref, $hash, $epoch, $tree, $desc, $text) = $fields; | |||||
| $branch = $this->getBranchNameFromRef($ref); | $branch = $this->getBranchNameFromRef($ref); | ||||
| if ($branch) { | if ($branch) { | ||||
| $result[] = array( | $result[] = array( | ||||
| 'current' => ($branch === $current), | 'current' => ($branch === $current), | ||||
| 'name' => $branch, | 'name' => $branch, | ||||
| 'hash' => $hash, | |||||
| 'tree' => $tree, | |||||
| 'epoch' => (int)$epoch, | |||||
| 'desc' => $desc, | |||||
| 'text' => $text, | |||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| public function getWorkingCopyRevision() { | public function getWorkingCopyRevision() { | ||||
| ▲ Show 20 Lines • Show All 440 Lines • Show Last 20 Lines | |||||