Path: blob/master/src/applications/diffusion/conduit/DiffusionGetRecentCommitsByPathConduitAPIMethod.php
12242 views
<?php12final class DiffusionGetRecentCommitsByPathConduitAPIMethod3extends DiffusionConduitAPIMethod {45const DEFAULT_LIMIT = 10;67public function getAPIMethodName() {8return 'diffusion.getrecentcommitsbypath';9}1011public function getMethodStatus() {12return self::METHOD_STATUS_DEPRECATED;13}1415public function getMethodStatusDescription() {16return pht('Obsoleted by "diffusion.historyquery".');17}1819public function getMethodDescription() {20return pht(21'Get commit identifiers for recent commits affecting a given path.');22}2324protected function defineParamTypes() {25return array(26'callsign' => 'required string',27'path' => 'required string',28'branch' => 'optional string',29'limit' => 'optional int',30);31}3233protected function defineErrorTypes() {34return array(35'ERR_NOT_FOUND' => pht('Repository was not found.'),36);37}3839protected function defineReturnType() {40return 'nonempty list<string>';41}4243protected function execute(ConduitAPIRequest $request) {44$drequest = DiffusionRequest::newFromDictionary(45array(46'user' => $request->getUser(),47'callsign' => $request->getValue('callsign'),48'path' => $request->getValue('path'),49'branch' => $request->getValue('branch'),50));5152if ($drequest === null) {53throw new ConduitException('ERR_NOT_FOUND');54}5556$limit = nonempty(57$request->getValue('limit'),58self::DEFAULT_LIMIT);5960$history_result = DiffusionQuery::callConduitWithDiffusionRequest(61$request->getUser(),62$drequest,63'diffusion.historyquery',64array(65'commit' => $drequest->getCommit(),66'path' => $drequest->getPath(),67'offset' => 0,68'limit' => $limit,69'needDirectChanges' => true,70'needChildChanges' => true,71));72$history = DiffusionPathChange::newFromConduit(73$history_result['pathChanges']);7475$raw_commit_identifiers = mpull($history, 'getCommitIdentifier');76$result = array();77foreach ($raw_commit_identifiers as $id) {78$result[] = 'r'.$request->getValue('callsign').$id;79}80return $result;81}8283}848586