Path: blob/master/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php
12242 views
<?php12final class DiffusionQueryCommitsConduitAPIMethod3extends DiffusionConduitAPIMethod {45public function getAPIMethodName() {6return 'diffusion.querycommits';7}89public function getMethodDescription() {10return pht('Retrieve information about commits.');11}1213public function getMethodStatus() {14return self::METHOD_STATUS_FROZEN;15}1617public function getMethodStatusDescription() {18return pht(19'This method is frozen and will eventually be deprecated. New code '.20'should use "diffusion.commit.search" instead.');21}2223protected function defineReturnType() {24return 'map<string, dict>';25}2627protected function defineParamTypes() {28return array(29'ids' => 'optional list<int>',30'phids' => 'optional list<phid>',31'names' => 'optional list<string>',32'repositoryPHID' => 'optional phid',33'needMessages' => 'optional bool',34'bypassCache' => 'optional bool',35) + $this->getPagerParamTypes();36}3738protected function execute(ConduitAPIRequest $request) {39$need_messages = $request->getValue('needMessages');40$viewer = $request->getUser();4142$query = id(new DiffusionCommitQuery())43->setViewer($viewer)44->needCommitData(true);4546$repository_phid = $request->getValue('repositoryPHID');47if ($repository_phid) {48$repository = id(new PhabricatorRepositoryQuery())49->setViewer($viewer)50->withPHIDs(array($repository_phid))51->executeOne();52if ($repository) {53$query->withRepository($repository);54}55}5657$names = $request->getValue('names');58if ($names) {59$query->withIdentifiers($names);60}6162$ids = $request->getValue('ids');63if ($ids) {64$query->withIDs($ids);65}6667$phids = $request->getValue('phids');68if ($phids) {69$query->withPHIDs($phids);70}7172$pager = $this->newPager($request);73$commits = $query->executeWithCursorPager($pager);7475$map = $query->getIdentifierMap();76$map = mpull($map, 'getPHID');7778$data = array();79foreach ($commits as $commit) {80$commit_data = $commit->getCommitData();8182$uri = $commit->getURI();83$uri = PhabricatorEnv::getProductionURI($uri);8485$dict = array(86'id' => $commit->getID(),87'phid' => $commit->getPHID(),88'repositoryPHID' => $commit->getRepository()->getPHID(),89'identifier' => $commit->getCommitIdentifier(),90'epoch' => $commit->getEpoch(),91'authorEpoch' => $commit_data->getAuthorEpoch(),92'uri' => $uri,93'isImporting' => !$commit->isImported(),94'summary' => $commit->getSummary(),95'authorPHID' => $commit->getAuthorPHID(),96'committerPHID' => $commit_data->getCommitDetail('committerPHID'),97'author' => $commit_data->getAuthorString(),98'authorName' => $commit_data->getAuthorDisplayName(),99'authorEmail' => $commit_data->getAuthorEmail(),100'committer' => $commit_data->getCommitterString(),101'committerName' => $commit_data->getCommitterDisplayName(),102'committerEmail' => $commit_data->getCommitterEmail(),103'hashes' => array(),104);105106if ($need_messages) {107$dict['message'] = $commit_data->getCommitMessage();108}109110$data[$commit->getPHID()] = $dict;111}112113$result = array(114'data' => $data,115'identifierMap' => nonempty($map, (object)array()),116);117118return $this->addPagerResults($result, $pager);119}120121}122123124