1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-21 04:01:29 +01:00
phorge-arcanist/src/loader/ArcanistGitCommitMessageHardpointLoader.php
epriestley 84857e4890 Implement a revision resolver for arc browse <commit>
Summary: Ref T10895. This allows `arc browse <commit name>` to resolve to a revision, if an associated open revision exists.

Test Plan: Ran `arc browse` with various arguments.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10895

Differential Revision: https://secure.phabricator.com/D16933
2016-11-23 13:27:26 -08:00

41 lines
940 B
PHP

<?php
final class ArcanistGitCommitMessageHardpointLoader
extends ArcanistGitHardpointLoader {
const LOADERKEY = 'git.commit.message';
public function canLoadRef(ArcanistRef $ref) {
return ($ref instanceof ArcanistCommitRef);
}
public function canLoadHardpoint(ArcanistRef $ref, $hardpoint) {
return ($hardpoint == 'message');
}
public function loadHardpoints(array $refs, $hardpoint) {
$api = $this->getQuery()->getRepositoryAPI();
$futures = array();
foreach ($refs as $ref_key => $ref) {
$hash = $ref->getCommitHash();
$futures[$ref_key] = $api->execFutureLocal(
'log -n1 --format=%C %s --',
'%s%n%n%b',
$hash);
}
$iterator = $this->newFutureIterator($futures);
$results = array();
foreach ($iterator as $ref_key => $future) {
list($stdout) = $future->resolvex();
$results[$ref_key] = $stdout;
}
return $results;
}
}