mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Update PhabricatorRepositoryManagementLookupUsersWorkflow to use ConduitCall
Summary: Ref T2783. This updates PhabricatorRepositoryManagementLookupUsersWorkflow to use ConduitCall to retrieve information about the commit. Test Plan: Ran `bin/repository lookup-users rTESTe9683b64d3283f0b2d355fdbf231bc918b5ac0ab --trace` and saw the information returned (by making a request to `diffusion.querycommits` as the omnipotent user, signed with the device key). Mucked with `cluster.addresses` and saw requests rejected. Reviewers: hach-que, btrahan Reviewed By: btrahan Subscribers: Krenair, epriestley, Korvin Maniphest Tasks: T2783 Differential Revision: https://secure.phabricator.com/D10403
This commit is contained in:
parent
fa7bb8ff7a
commit
4f4dc9c83e
2 changed files with 39 additions and 4 deletions
|
@ -9,6 +9,26 @@ final class DiffusionCommitRef extends Phobject {
|
|||
private $committerEmail;
|
||||
private $hashes = array();
|
||||
|
||||
public static function newFromConduitResult(array $result) {
|
||||
$ref = id(new DiffusionCommitRef())
|
||||
->setCommitterEmail(idx($result, 'committerEmail'))
|
||||
->setCommitterName(idx($result, 'committerName'))
|
||||
->setAuthorEmail(idx($result, 'authorEmail'))
|
||||
->setAuthorName(idx($result, 'authorName'))
|
||||
->setMessage(idx($result, 'message'));
|
||||
|
||||
$hashes = array();
|
||||
foreach (idx($result, 'hashes', array()) as $hash_result) {
|
||||
$hashes[] = id(new DiffusionCommitHash())
|
||||
->setHashType(idx($hash_result, 'type'))
|
||||
->setHashValue(idx($hash_result, 'value'));
|
||||
}
|
||||
|
||||
$ref->setHashes($hashes);
|
||||
|
||||
return $ref;
|
||||
}
|
||||
|
||||
public function setHashes(array $hashes) {
|
||||
$this->hashes = $hashes;
|
||||
return $this;
|
||||
|
|
|
@ -33,10 +33,25 @@ final class PhabricatorRepositoryManagementLookupUsersWorkflow
|
|||
"%s\n",
|
||||
pht('Examining commit %s...', $name));
|
||||
|
||||
$ref = id(new DiffusionLowLevelCommitQuery())
|
||||
->setRepository($repo)
|
||||
->withIdentifier($commit->getCommitIdentifier())
|
||||
->execute();
|
||||
$refs_raw = DiffusionQuery::callConduitWithDiffusionRequest(
|
||||
$this->getViewer(),
|
||||
DiffusionRequest::newFromDictionary(
|
||||
array(
|
||||
'repository' => $repo,
|
||||
'user' => $this->getViewer(),
|
||||
)),
|
||||
'diffusion.querycommits',
|
||||
array(
|
||||
'phids' => array($commit->getPHID()),
|
||||
'bypassCache' => true,
|
||||
));
|
||||
|
||||
if (empty($refs_raw['data'])) {
|
||||
throw new Exception(
|
||||
pht('Unable to retrieve details for commit "%s"!'));
|
||||
}
|
||||
|
||||
$ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data']));
|
||||
|
||||
$author = $ref->getAuthor();
|
||||
$console->writeOut(
|
||||
|
|
Loading…
Reference in a new issue