From d7f51325e3ab0ebc22d5823d6423cb4533c28e83 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Wed, 3 Sep 2014 22:49:44 +1000 Subject: [PATCH] Populate results of DiffusionQueryCommitsConduitAPIMethod with DiffusionLowLevelCommitQuery Summary: Ref T2783. This populates the following fields in DiffusionQueryCommitsConduitAPIMethod using DiffusionLowLevelCommitQuery when `bypassCache` is set to true: * `authorName` * `authorEmail` * `committerName` * `committerEmail` * `message` * `hashes` The original outline called for `authorPHID` and `committerPHID` as well (but no `message` field). As far as I can tell, the PHIDs aren't actual a property on `DiffusionCommitRef`, and since the intention of this is to be able to populate a `DiffusionCommitRef`, I haven't included them. Let me know if we really do need the PHIDs here. Test Plan: Tested using 3 Phabricator instances (one web, one taskmaster and one storage). The web and taskmaster tiers are directed at the Conduit API of the storage tier. Made a `diffusion.querycommits` from the Conduit app on the web tier instance and saw the data populated from the raw VCS data (located on the storage tier). Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T2783 Differential Revision: https://secure.phabricator.com/D10399 --- .../DiffusionQueryCommitsConduitAPIMethod.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php index 28ed411df3..6d936d52b7 100644 --- a/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php @@ -22,6 +22,7 @@ final class DiffusionQueryCommitsConduitAPIMethod 'names' => 'optional list', 'repositoryPHID' => 'optional phid', 'needMessages' => 'optional bool', + 'bypassCache' => 'optional bool', ) + $this->getPagerParamTypes(); } @@ -31,6 +32,7 @@ final class DiffusionQueryCommitsConduitAPIMethod protected function execute(ConduitAPIRequest $request) { $need_messages = $request->getValue('needMessages'); + $bypass_cache = $request->getValue('bypassCache'); $query = id(new DiffusionCommitQuery()) ->setViewer($request->getUser()); @@ -87,8 +89,35 @@ final class DiffusionQueryCommitsConduitAPIMethod 'uri' => $uri, 'isImporting' => !$commit->isImported(), 'summary' => $commit->getSummary(), + 'authorName' => '', + 'authorEmail' => '', + 'committerName' => '', + 'committerEmail' => '', + 'hashes' => array(), ); + if ($bypass_cache) { + $lowlevel_commitref = id(new DiffusionLowLevelCommitQuery()) + ->setRepository($commit->getRepository()) + ->withIdentifier($commit->getCommitIdentifier()) + ->execute(); + + $dict['authorName'] = $lowlevel_commitref->getAuthorName(); + $dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail(); + $dict['committerName'] = $lowlevel_commitref->getCommitterName(); + $dict['committerEmail'] = $lowlevel_commitref->getCommitterEmail(); + + if ($need_messages) { + $dict['message'] = $lowlevel_commitref->getMessage(); + } + + foreach ($lowlevel_commitref->getHashes() as $hash) { + $dict['hashes'][] = array( + 'type' => $hash->getHashType(), + 'value' => $hash->getHashValue()); + } + } + if ($need_messages) { $commit_data = $commit->getCommitData(); if ($commit_data) {