1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-02-13 23:38:33 +01:00
phorge-arcanist/src/query/ArcanistGitCommitMessageHardpointQuery.php
epriestley 8bb81217d5 Bring a "pro" WorkingCopyState ref to "master"
Summary:
Ref T11968. Continue bringing modern yield-based hardpoint code into "master" in the parallel "Pro" classtree.

Adds "working-copy(commit-hash)" as an inspectable ref.

Test Plan: Inspected working copy refs, saw them resolve revisions by commit hash and commit message.

Maniphest Tasks: T11968

Differential Revision: https://secure.phabricator.com/D21079
2020-04-10 06:16:37 -07:00

48 lines
1.2 KiB
PHP

<?php
final class ArcanistGitCommitMessageHardpointQuery
extends ArcanistWorkflowGitHardpointQuery {
public function getHardpoints() {
return array(
ArcanistCommitRefPro::HARDPOINT_MESSAGE,
);
}
protected function canLoadRef(ArcanistRefPro $ref) {
return ($ref instanceof ArcanistCommitRefPro);
}
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);
}
}