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

diffusion.getrecentcommitsbypath

Summary:
Implement diffusion.getrecentcommitsbypath, a Conduit wrapper over
DiffusionHistoryQuery which returns results suitable for consumption by
diffusion.getcommits.

Test Plan:
Conduit console

Reviewed By: epriestley
Reviewers: epriestley
CC: aran, epriestley
Differential Revision: 315
This commit is contained in:
adonohue 2011-05-19 15:36:17 -07:00
parent 5fdea30878
commit 36a6fcb573
4 changed files with 81 additions and 0 deletions

View file

@ -95,6 +95,7 @@ phutil_register_library_map(array(
'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision',
'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'applications/conduit/method/differential/updatetaskrevisionassoc',
'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/conduit/method/diffusion/getrecentcommitsbypath',
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners',
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
@ -588,6 +589,7 @@ phutil_register_library_map(array(
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod',
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod',
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',

View file

@ -0,0 +1,62 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ConduitAPI_diffusion_getrecentcommitsbypath_Method
extends ConduitAPIMethod {
const RESULT_LIMIT = 10;
public function getMethodDescription() {
return "Get commit identifiers for recent commits affecting a given path.";
}
public function defineParamTypes() {
return array(
'callsign' => 'required string',
'path' => 'required string',
);
}
public function defineReturnType() {
return 'nonempty list<string>';
}
public function defineErrorTypes() {
return array(
);
}
protected function execute(ConduitAPIRequest $request) {
$results = array();
$history = DiffusionHistoryQuery::newFromDiffusionRequest(
DiffusionRequest::newFromAphrontRequestDictionary(
$request->getAllParameters()
)
)
->setLimit(self::RESULT_LIMIT)
->loadHistory();
$raw_commit_identifiers = mpull($history, 'getCommitIdentifier');
$result = array();
foreach ($raw_commit_identifiers as $id) {
$result[] = 'r'.$request->getValue('callsign').$id;
}
return $result;
}
}

View file

@ -0,0 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/conduit/method/base');
phutil_require_module('phabricator', 'applications/diffusion/query/history/base');
phutil_require_module('phabricator', 'applications/diffusion/request/base');
phutil_require_module('phutil', 'utils');
phutil_require_source('ConduitAPI_diffusion_getrecentcommitsbypath_Method.php');

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'aphront/response/304');
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/file');
phutil_require_module('phabricator', 'infrastructure/celerity/map');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'moduleutils');