1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +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');
$query = id(new DiffusionCommitQuery())
->setViewer($request->getUser());
if ($need_messages) {
$query->needCommitData(true);
}
->setViewer($request->getUser())
->needCommitData(true);
$repository_phid = $request->getValue('repositoryPHID');
if ($repository_phid) {
@ -75,6 +72,8 @@ final class DiffusionQueryCommitsConduitAPIMethod
$data = array();
foreach ($commits as $commit) {
$commit_data = $commit->getCommitData();
$callsign = $commit->getRepository()->getCallsign();
$identifier = $commit->getCommitIdentifier();
$uri = '/r'.$callsign.$identifier;
@ -89,10 +88,14 @@ final class DiffusionQueryCommitsConduitAPIMethod
'uri' => $uri,
'isImporting' => !$commit->isImported(),
'summary' => $commit->getSummary(),
'authorName' => '',
'authorEmail' => '',
'committerName' => '',
'committerEmail' => '',
'authorPHID' => $commit->getAuthorPHID(),
'committerPHID' => $commit_data->getCommitDetail('committerPHID'),
'author' => $commit_data->getAuthorName(),
'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(),
);
@ -102,8 +105,10 @@ final class DiffusionQueryCommitsConduitAPIMethod
->withIdentifier($commit->getCommitIdentifier())
->execute();
$dict['author'] = $lowlevel_commitref->getAuthor();
$dict['authorName'] = $lowlevel_commitref->getAuthorName();
$dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail();
$dict['committer'] = $lowlevel_commitref->getCommitter();
$dict['committerName'] = $lowlevel_commitref->getCommitterName();
$dict['committerEmail'] = $lowlevel_commitref->getCommitterEmail();
@ -118,13 +123,8 @@ final class DiffusionQueryCommitsConduitAPIMethod
}
}
if ($need_messages) {
$commit_data = $commit->getCommitData();
if ($commit_data) {
$dict['message'] = $commit_data->getCommitMessage();
} else {
$dict['message'] = null;
}
if ($need_messages && !$bypass_cache) {
$dict['message'] = $commit_data->getCommitMessage();
}
$data[$commit->getPHID()] = $dict;

View file

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