Changeset View
Changeset View
Standalone View
Standalone View
src/repository/marker/ArcanistGitRepositoryMarkerQuery.php
| Show All 17 Lines | $field_list = array( | ||||
| '%(subject)%0a%0a%(body)', | '%(subject)%0a%0a%(body)', | ||||
| '%02', | '%02', | ||||
| ); | ); | ||||
| $expect_count = count($field_list); | $expect_count = count($field_list); | ||||
| $branch_prefix = 'refs/heads/'; | $branch_prefix = 'refs/heads/'; | ||||
| $branch_length = strlen($branch_prefix); | $branch_length = strlen($branch_prefix); | ||||
| // NOTE: Since we only return branches today, we restrict this operation | $remote_prefix = 'refs/remotes/'; | ||||
| // to branches. | $remote_length = strlen($remote_prefix); | ||||
| list($stdout) = $api->newFuture( | list($stdout) = $api->newFuture( | ||||
| 'for-each-ref --format %s -- refs/heads/', | 'for-each-ref --format %s -- refs/', | ||||
| implode('%01', $field_list))->resolve(); | implode('%01', $field_list))->resolve(); | ||||
| $markers = array(); | $markers = array(); | ||||
| $lines = explode("\2", $stdout); | $lines = explode("\2", $stdout); | ||||
| foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
| $line = trim($line); | $line = trim($line); | ||||
| if (!strlen($line)) { | if (!strlen($line)) { | ||||
| Show All 9 Lines | foreach ($lines as $line) { | ||||
| 'expected %s.', | 'expected %s.', | ||||
| $line, | $line, | ||||
| new PhutilNumber($actual_count), | new PhutilNumber($actual_count), | ||||
| new PhutilNumber($expect_count))); | new PhutilNumber($expect_count))); | ||||
| } | } | ||||
| list($ref, $hash, $epoch, $tree, $dst_hash, $summary, $text) = $fields; | list($ref, $hash, $epoch, $tree, $dst_hash, $summary, $text) = $fields; | ||||
| $remote_name = null; | |||||
| if (!strncmp($ref, $branch_prefix, $branch_length)) { | if (!strncmp($ref, $branch_prefix, $branch_length)) { | ||||
| $type = ArcanistMarkerRef::TYPE_BRANCH; | $type = ArcanistMarkerRef::TYPE_BRANCH; | ||||
| $name = substr($ref, $branch_length); | $name = substr($ref, $branch_length); | ||||
| } else if (!strncmp($ref, $remote_prefix, $remote_length)) { | |||||
| // This isn't entirely correct: the ref may be a tag, etc. | |||||
| $type = ArcanistMarkerRef::TYPE_BRANCH; | |||||
| $label = substr($ref, $remote_length); | |||||
| $parts = explode('/', $label, 2); | |||||
| $remote_name = $parts[0]; | |||||
| $name = $parts[1]; | |||||
| } else { | } else { | ||||
| // For now, discard other refs. | // For now, discard other refs. | ||||
| continue; | continue; | ||||
| } | } | ||||
| $marker = id(new ArcanistMarkerRef()) | $marker = id(new ArcanistMarkerRef()) | ||||
| ->setName($name) | ->setName($name) | ||||
| ->setMarkerType($type) | ->setMarkerType($type) | ||||
| ->setEpoch((int)$epoch) | ->setEpoch((int)$epoch) | ||||
| ->setMarkerHash($hash) | ->setMarkerHash($hash) | ||||
| ->setTreeHash($tree) | ->setTreeHash($tree) | ||||
| ->setSummary($summary) | ->setSummary($summary) | ||||
| ->setMessage($text); | ->setMessage($text); | ||||
| if ($remote_name !== null) { | |||||
| $marker->setRemoteName($remote_name); | |||||
| } | |||||
| if (strlen($dst_hash)) { | if (strlen($dst_hash)) { | ||||
| $commit_hash = $dst_hash; | $commit_hash = $dst_hash; | ||||
| } else { | } else { | ||||
| $commit_hash = $hash; | $commit_hash = $hash; | ||||
| } | } | ||||
| $marker->setCommitHash($commit_hash); | $marker->setCommitHash($commit_hash); | ||||
| ▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines | |||||