1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-03-29 04:28:11 +01:00
phorge-arcanist/src/query/ArcanistGitCommitMessageHardpointQuery.php
epriestley adea2550f5 Introduce "arc inspect" and some of the new ref/hardpoint classes
Summary:
Ref T11968. Inches toward the new ref/hardpoint code by introducing the modern refs as "RefPro" objects and supporting an "arc inspect <object>" to load objects and hardpoints.

This doesn't impact any existing runtime behavior.

Test Plan: Ran "arc inspect [--all] commit(...)", got hardpoint queries and yield-based data fetching.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21078
2020-04-10 05:01:25 -07:00

53 lines
1.3 KiB
PHP

<?php
final class ArcanistGitCommitMessageHardpointQuery
extends ArcanistWorkflowHardpointQuery {
public function getHardpoints() {
return array(
ArcanistCommitRefPro::HARDPOINT_MESSAGE,
);
}
protected function canLoadRef(ArcanistRefPro $ref) {
return ($ref instanceof ArcanistCommitRefPro);
}
protected function canLoadHardpoint() {
$api = $this->getRepositoryAPI();
return ($api instanceof ArcanistGitAPI);
}
public function loadHardpoint(array $refs, $hardpoint) {
$api = $this->getRepositoryAPI();
$hashes = mpull($refs, 'getCommitHash');
$unique_hashes = array_fuse($hashes);
// TODO: Update this to use "%B", see T5028. We can also bulk-resolve
// these with "git show --quiet --format=... hash hash hash ... --".
$futures = array();
foreach ($unique_hashes as $hash) {
$futures[$hash] = $api->execFutureLocal(
'log -n1 --format=%s %s --',
'%s%n%n%b',
$hash);
}
yield $this->yieldFutures($futures);
$messages = array();
foreach ($futures as $hash => $future) {
list($stdout) = $future->resolvex();
$messages[$hash] = $stdout;
}
foreach ($hashes as $ref_key => $hash) {
$hashes[$ref_key] = $messages[$hash];
}
yield $this->yieldMap($hashes);
}
}