1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +01:00

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
This commit is contained in:
James Rhodes 2014-09-03 22:49:44 +10:00
parent df3ddd5de4
commit d7f51325e3

View file

@ -22,6 +22,7 @@ final class DiffusionQueryCommitsConduitAPIMethod
'names' => 'optional list<string>',
'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) {