From 4f4dc9c83e8a297aa4cf05e17f8bd97491c1770c Mon Sep 17 00:00:00 2001 From: epriestley <git@epriestley.com> Date: Fri, 2 Jan 2015 15:13:57 -0800 Subject: [PATCH] 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 --- .../diffusion/data/DiffusionCommitRef.php | 20 ++++++++++++++++ ...epositoryManagementLookupUsersWorkflow.php | 23 +++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/applications/diffusion/data/DiffusionCommitRef.php b/src/applications/diffusion/data/DiffusionCommitRef.php index 4d6b99d8a6..a3b10c2764 100644 --- a/src/applications/diffusion/data/DiffusionCommitRef.php +++ b/src/applications/diffusion/data/DiffusionCommitRef.php @@ -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; diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php index dc2781ea05..c06cdcd1f4 100644 --- a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php @@ -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(