1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Provide more information from diffusion.querycommits

Summary:
Ref T2783. Fixes T6039.

  - Provide `authorPHID` and `committerPHID` to resolve T6039.
  - In message parser, store author/email strings.
  - In cached results, emit author/email strings.

Test Plan: Called method with and without bypassCache. Used `reparse.php` to repopulate data on an old commit.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2783, T6039

Differential Revision: https://secure.phabricator.com/D10424
This commit is contained in:
epriestley 2014-09-05 12:27:55 -07:00
parent 25f4a23a95
commit ac4247ea59
2 changed files with 24 additions and 16 deletions

View file

@ -35,11 +35,8 @@ final class DiffusionQueryCommitsConduitAPIMethod
$bypass_cache = $request->getValue('bypassCache'); $bypass_cache = $request->getValue('bypassCache');
$query = id(new DiffusionCommitQuery()) $query = id(new DiffusionCommitQuery())
->setViewer($request->getUser()); ->setViewer($request->getUser())
->needCommitData(true);
if ($need_messages) {
$query->needCommitData(true);
}
$repository_phid = $request->getValue('repositoryPHID'); $repository_phid = $request->getValue('repositoryPHID');
if ($repository_phid) { if ($repository_phid) {
@ -75,6 +72,8 @@ final class DiffusionQueryCommitsConduitAPIMethod
$data = array(); $data = array();
foreach ($commits as $commit) { foreach ($commits as $commit) {
$commit_data = $commit->getCommitData();
$callsign = $commit->getRepository()->getCallsign(); $callsign = $commit->getRepository()->getCallsign();
$identifier = $commit->getCommitIdentifier(); $identifier = $commit->getCommitIdentifier();
$uri = '/r'.$callsign.$identifier; $uri = '/r'.$callsign.$identifier;
@ -89,10 +88,14 @@ final class DiffusionQueryCommitsConduitAPIMethod
'uri' => $uri, 'uri' => $uri,
'isImporting' => !$commit->isImported(), 'isImporting' => !$commit->isImported(),
'summary' => $commit->getSummary(), 'summary' => $commit->getSummary(),
'authorName' => '', 'authorPHID' => $commit->getAuthorPHID(),
'authorEmail' => '', 'committerPHID' => $commit_data->getCommitDetail('committerPHID'),
'committerName' => '', 'author' => $commit_data->getAuthorName(),
'committerEmail' => '', 'authorName' => $commit_data->getCommitDetail('authorName'),
'authorEmail' => $commit_data->getCommitDetail('authorEmail'),
'committer' => $commit_data->getCommitDetail('committer'),
'committerName' => $commit_data->getCommitDetail('committerName'),
'committerEmail' => $commit_data->getCommitDetail('committerEmail'),
'hashes' => array(), 'hashes' => array(),
); );
@ -102,8 +105,10 @@ final class DiffusionQueryCommitsConduitAPIMethod
->withIdentifier($commit->getCommitIdentifier()) ->withIdentifier($commit->getCommitIdentifier())
->execute(); ->execute();
$dict['author'] = $lowlevel_commitref->getAuthor();
$dict['authorName'] = $lowlevel_commitref->getAuthorName(); $dict['authorName'] = $lowlevel_commitref->getAuthorName();
$dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail(); $dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail();
$dict['committer'] = $lowlevel_commitref->getCommitter();
$dict['committerName'] = $lowlevel_commitref->getCommitterName(); $dict['committerName'] = $lowlevel_commitref->getCommitterName();
$dict['committerEmail'] = $lowlevel_commitref->getCommitterEmail(); $dict['committerEmail'] = $lowlevel_commitref->getCommitterEmail();
@ -118,13 +123,8 @@ final class DiffusionQueryCommitsConduitAPIMethod
} }
} }
if ($need_messages) { if ($need_messages && !$bypass_cache) {
$commit_data = $commit->getCommitData();
if ($commit_data) {
$dict['message'] = $commit_data->getCommitMessage(); $dict['message'] = $commit_data->getCommitMessage();
} else {
$dict['message'] = null;
}
} }
$data[$commit->getPHID()] = $dict; $data[$commit->getPHID()] = $dict;

View file

@ -18,6 +18,10 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
} }
$data->setCommitID($commit->getID()); $data->setCommitID($commit->getID());
$data->setAuthorName((string)$author); $data->setAuthorName((string)$author);
$data->setCommitDetail('authorName', $ref->getAuthorName());
$data->setCommitDetail('authorEmail', $ref->getAuthorEmail());
$data->setCommitDetail( $data->setCommitDetail(
'authorPHID', 'authorPHID',
$this->resolveUserPHID($commit, $author)); $this->resolveUserPHID($commit, $author));
@ -26,6 +30,10 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker
if (strlen($committer)) { if (strlen($committer)) {
$data->setCommitDetail('committer', $committer); $data->setCommitDetail('committer', $committer);
$data->setCommitDetail('committerName', $ref->getCommitterName());
$data->setCommitDetail('committerEmail', $ref->getCommitterEmail());
$data->setCommitDetail( $data->setCommitDetail(
'committerPHID', 'committerPHID',
$this->resolveUserPHID($commit, $committer)); $this->resolveUserPHID($commit, $committer));