1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-31 18:01:00 +01:00

Add Conduit method for getting Diffusion lint messages

Test Plan: /conduit/method/diffusion.getlintmessages/, ran it, saw results.

Reviewers: epriestley, wez

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2038

Differential Revision: https://secure.phabricator.com/D3932
This commit is contained in:
vrana 2012-11-08 17:16:23 -08:00
parent 416d26b621
commit 493196e16a
2 changed files with 73 additions and 0 deletions

View file

@ -139,6 +139,7 @@ phutil_register_library_map(array(
'ConduitAPI_differential_updateunitresults_Method' => 'applications/conduit/method/differential/ConduitAPI_differential_updateunitresults_Method.php',
'ConduitAPI_diffusion_findsymbols_Method' => 'applications/conduit/method/diffusion/ConduitAPI_diffusion_findsymbols_Method.php',
'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/ConduitAPI_diffusion_getcommits_Method.php',
'ConduitAPI_diffusion_getlintmessages_Method' => 'applications/conduit/method/diffusion/ConduitAPI_diffusion_getlintmessages_Method.php',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/conduit/method/diffusion/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php',
'ConduitAPI_feed_publish_Method' => 'applications/conduit/method/feed/ConduitAPI_feed_publish_Method.php',
'ConduitAPI_feed_query_Method' => 'applications/conduit/method/feed/ConduitAPI_feed_query_Method.php',
@ -1428,6 +1429,7 @@ phutil_register_library_map(array(
'ConduitAPI_differential_updateunitresults_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_findsymbols_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getlintmessages_Method' => 'ConduitAPIMethod',
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPIMethod',
'ConduitAPI_feed_publish_Method' => 'ConduitAPIMethod',
'ConduitAPI_feed_query_Method' => 'ConduitAPIMethod',

View file

@ -0,0 +1,71 @@
<?php
/**
* @group conduit
*/
final class ConduitAPI_diffusion_getlintmessages_Method
extends ConduitAPIMethod {
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return "Get lint messages for existing code.";
}
public function defineParamTypes() {
return array(
'arcanistProject' => 'required string',
'branch' => 'optional string',
'commit' => 'optional string',
'files' => 'required list<string>',
);
}
public function defineReturnType() {
return 'list<dict>';
}
public function defineErrorTypes() {
return array(
);
}
protected function execute(ConduitAPIRequest $request) {
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
'name = %s',
$request->getValue('arcanistProject'));
if (!$project || !$project->getRepositoryID()) {
return array();
}
$branch_name = $request->getValue('branch');
if ($branch_name == '') {
$repository = id(new PhabricatorRepository())
->load($project->getRepositoryID());
$branch_name = $repository->getDefaultArcanistBranch();
}
$branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(
'repositoryID = %d AND name = %s',
$project->getRepositoryID(),
$branch_name);
if (!$branch || !$branch->getLintCommit()) {
return array();
}
$lint_messages = queryfx_all(
$branch->establishConnection('r'),
'SELECT path, line, code FROM %T WHERE branchID = %d AND path IN (%Ls)',
PhabricatorRepository::TABLE_LINTMESSAGE,
$branch->getID(),
$request->getValue('files'));
// TODO: Compare commit identifiers of individual files like in
// DiffusionBrowseFileController::loadLintMessages().
return $lint_messages;
}
}