@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 71 lines 2.0 kB view raw
1<?php 2 3final class DiffusionGetLintMessagesConduitAPIMethod 4 extends DiffusionConduitAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'diffusion.getlintmessages'; 8 } 9 10 public function getMethodDescription() { 11 return pht('Get lint messages for existing code.'); 12 } 13 14 protected function defineParamTypes() { 15 return array( 16 'repositoryPHID' => 'required phid', 17 'branch' => 'required string', 18 'commit' => 'optional string', 19 'files' => 'required list<string>', 20 ); 21 } 22 23 protected function defineReturnType() { 24 return 'list<dict>'; 25 } 26 27 protected function execute(ConduitAPIRequest $request) { 28 $viewer = $request->getUser(); 29 30 $repository_phid = $request->getValue('repositoryPHID'); 31 $repository = id(new PhabricatorRepositoryQuery()) 32 ->setViewer($viewer) 33 ->withPHIDs(array($repository_phid)) 34 ->executeOne(); 35 36 if (!$repository) { 37 throw new Exception( 38 pht('No repository exists with PHID "%s".', $repository_phid)); 39 } 40 41 $branch_name = $request->getValue('branch'); 42 if ($branch_name == '') { 43 $repository = id(new PhabricatorRepositoryQuery()) 44 ->setViewer($request->getUser()) 45 ->withIDs(array($repository->getID())) 46 ->executeOne(); 47 $branch_name = $repository->getDefaultArcanistBranch(); 48 } 49 50 $branch = id(new PhabricatorRepositoryBranch())->loadOneWhere( 51 'repositoryID = %d AND name = %s', 52 $repository->getID(), 53 $branch_name); 54 if (!$branch || !$branch->getLintCommit()) { 55 return array(); 56 } 57 58 $lint_messages = queryfx_all( 59 $branch->establishConnection('r'), 60 'SELECT path, line, code FROM %T WHERE branchID = %d AND path IN (%Ls)', 61 PhabricatorRepository::TABLE_LINTMESSAGE, 62 $branch->getID(), 63 $request->getValue('files')); 64 65 // TODO: Compare commit identifiers of individual files like in 66 // DiffusionBrowseFileController::loadLintMessages(). 67 68 return $lint_messages; 69 } 70 71}