Differential D21447 Diff 51081 src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php
| Show All 32 Lines | return array( | ||||
| 'repositoryPHID' => 'optional phid', | 'repositoryPHID' => 'optional phid', | ||||
| 'needMessages' => 'optional bool', | 'needMessages' => 'optional bool', | ||||
| 'bypassCache' => 'optional bool', | 'bypassCache' => 'optional bool', | ||||
| ) + $this->getPagerParamTypes(); | ) + $this->getPagerParamTypes(); | ||||
| } | } | ||||
| protected function execute(ConduitAPIRequest $request) { | protected function execute(ConduitAPIRequest $request) { | ||||
| $need_messages = $request->getValue('needMessages'); | $need_messages = $request->getValue('needMessages'); | ||||
| $bypass_cache = $request->getValue('bypassCache'); | |||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $query = id(new DiffusionCommitQuery()) | $query = id(new DiffusionCommitQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->needCommitData(true); | ->needCommitData(true); | ||||
| $repository_phid = $request->getValue('repositoryPHID'); | $repository_phid = $request->getValue('repositoryPHID'); | ||||
| if ($repository_phid) { | if ($repository_phid) { | ||||
| $repository = id(new PhabricatorRepositoryQuery()) | $repository = id(new PhabricatorRepositoryQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs(array($repository_phid)) | ->withPHIDs(array($repository_phid)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if ($repository) { | if ($repository) { | ||||
| $query->withRepository($repository); | $query->withRepository($repository); | ||||
| if ($bypass_cache) { | |||||
| id(new DiffusionRepositoryClusterEngine()) | |||||
| ->setViewer($viewer) | |||||
| ->setRepository($repository) | |||||
| ->synchronizeWorkingCopyBeforeRead(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| $names = $request->getValue('names'); | $names = $request->getValue('names'); | ||||
| if ($names) { | if ($names) { | ||||
| $query->withIdentifiers($names); | $query->withIdentifiers($names); | ||||
| } | } | ||||
| Show All 36 Lines | foreach ($commits as $commit) { | ||||
| 'authorName' => $commit_data->getCommitDetail('authorName'), | 'authorName' => $commit_data->getCommitDetail('authorName'), | ||||
| 'authorEmail' => $commit_data->getCommitDetail('authorEmail'), | 'authorEmail' => $commit_data->getCommitDetail('authorEmail'), | ||||
| 'committer' => $commit_data->getCommitDetail('committer'), | 'committer' => $commit_data->getCommitDetail('committer'), | ||||
| 'committerName' => $commit_data->getCommitDetail('committerName'), | 'committerName' => $commit_data->getCommitDetail('committerName'), | ||||
| 'committerEmail' => $commit_data->getCommitDetail('committerEmail'), | 'committerEmail' => $commit_data->getCommitDetail('committerEmail'), | ||||
| 'hashes' => array(), | 'hashes' => array(), | ||||
| ); | ); | ||||
| if ($bypass_cache) { | |||||
| $lowlevel_commitref = id(new DiffusionLowLevelCommitQuery()) | |||||
| ->setRepository($commit->getRepository()) | |||||
| ->withIdentifier($commit->getCommitIdentifier()) | |||||
| ->execute(); | |||||
| $dict['authorEpoch'] = $lowlevel_commitref->getAuthorEpoch(); | |||||
| $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(); | |||||
| if ($need_messages) { | 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 && !$bypass_cache) { | |||||
| $dict['message'] = $commit_data->getCommitMessage(); | $dict['message'] = $commit_data->getCommitMessage(); | ||||
| } | } | ||||
| $data[$commit->getPHID()] = $dict; | $data[$commit->getPHID()] = $dict; | ||||
| } | } | ||||
| $result = array( | $result = array( | ||||
| 'data' => $data, | 'data' => $data, | ||||
| 'identifierMap' => nonempty($map, (object)array()), | 'identifierMap' => nonempty($map, (object)array()), | ||||
| ); | ); | ||||
| return $this->addPagerResults($result, $pager); | return $this->addPagerResults($result, $pager); | ||||
| } | } | ||||
| } | } | ||||