@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
1
fork

Configure Feed

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

Change "lint save" to not use Arcanist Projects

Summary: Ref T7604. Change `DiffusionLintSaveRunner` to use repositories instead of Arcanist Projects.

Test Plan: Ran the `save_lint.php` script and queried results using the `diffusion.getlintmessages` Conduit endpoint.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12893

+49 -26
+11 -8
scripts/repository/save_lint.php
··· 17 17 ->parse(array( 18 18 array( 19 19 'name' => 'all', 20 - 'help' => 20 + 'help' => pht( 21 21 'Discover problems in the whole repository instead of just changes '. 22 - 'since the last run.', 22 + 'since the last run.'), 23 23 ), 24 24 array( 25 25 'name' => 'arc', 26 26 'param' => 'path', 27 27 'default' => 'arc', 28 - 'help' => 'Path to Arcanist executable.', 28 + 'help' => pht('Path to Arcanist executable.'), 29 29 ), 30 30 array( 31 31 'name' => 'severity', 32 32 'param' => 'string', 33 33 'default' => ArcanistLintSeverity::SEVERITY_ADVICE, 34 - 'help' => 'Minimum severity, one of ArcanistLintSeverity constants.', 34 + 'help' => pht( 35 + 'Minimum severity, one of %s constants.', 36 + 'ArcanistLintSeverity'), 35 37 ), 36 38 array( 37 39 'name' => 'chunk-size', 38 40 'param' => 'number', 39 41 'default' => 256, 40 - 'help' => 'Number of paths passed to `arc` at once.', 42 + 'help' => pht('Number of paths passed to `%s` at once.', 'arc'), 41 43 ), 42 44 array( 43 45 'name' => 'blame', 44 - 'help' => 'Assign lint errors to authors who last modified the line.', 46 + 'help' => pht( 47 + 'Assign lint errors to authors who last modified the line.'), 45 48 ), 46 49 )); 47 50 48 - echo "Saving lint errors to database...\n"; 51 + echo pht('Saving lint errors to database...')."\n"; 49 52 50 53 $count = id(new DiffusionLintSaveRunner()) 51 54 ->setAll($args->getArg('all', false)) ··· 55 58 ->setNeedsBlame($args->getArg('blame')) 56 59 ->run('.'); 57 60 58 - echo "\nProcessed {$count} files.\n"; 61 + echo "\n".pht('Processed %d files.', $count)."\n";
+20 -6
src/applications/diffusion/DiffusionLintSaveRunner.php
··· 58 58 } 59 59 } 60 60 61 - $project_id = $working_copy->getProjectID(); 62 - $project = id(new PhabricatorRepositoryArcanistProject()) 63 - ->loadOneWhere('name = %s', $project_id); 64 - if (!$project || !$project->getRepositoryID()) { 65 - throw new Exception("Couldn't find repository for {$project_id}."); 61 + $callsign = $configuration_manager->getConfigFromAnySource( 62 + 'repository.callsign'); 63 + $uuid = $api->getRepositoryUUID(); 64 + $remote_uri = $api->getRemoteURI(); 65 + 66 + $repository_query = id(new PhabricatorRepositoryQuery()) 67 + ->setViewer(PhabricatorUser::getOmnipotentUser()); 68 + 69 + if ($callsign) { 70 + $repository_query->withCallsigns(array($callsign)); 71 + } else if ($uuid) { 72 + $repository_query->withUUIDs(array($uuid)); 73 + } else if ($remote_uri) { 74 + $repository_query->withRemoteURIs(array($remote_uri)); 66 75 } 67 76 77 + $repository = $repository_query->executeOne(); 68 78 $branch_name = $api->getBranchName(); 69 79 80 + if (!$repository) { 81 + throw new Exception(pht('No repository was found.')); 82 + } 83 + 70 84 $this->branch = PhabricatorRepositoryBranch::loadOrCreateBranch( 71 - $project->getRepositoryID(), 85 + $repository->getID(), 72 86 $branch_name); 73 87 $this->conn = $this->branch->establishConnection('w'); 74 88
+18 -12
src/applications/diffusion/conduit/DiffusionGetLintMessagesConduitAPIMethod.php
··· 12 12 } 13 13 14 14 public function getMethodDescription() { 15 - return 'Get lint messages for existing code.'; 15 + return pht('Get lint messages for existing code.'); 16 16 } 17 17 18 18 protected function defineParamTypes() { 19 19 return array( 20 - 'arcanistProject' => 'required string', 21 - 'branch' => 'optional string', 22 - 'commit' => 'optional string', 23 - 'files' => 'required list<string>', 20 + 'repositoryPHID' => 'required phid', 21 + 'branch' => 'required string', 22 + 'commit' => 'optional string', 23 + 'files' => 'required list<string>', 24 24 ); 25 25 } 26 26 ··· 29 29 } 30 30 31 31 protected function execute(ConduitAPIRequest $request) { 32 - $project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere( 33 - 'name = %s', 34 - $request->getValue('arcanistProject')); 35 - if (!$project || !$project->getRepositoryID()) { 36 - return array(); 32 + $viewer = $request->getUser(); 33 + 34 + $repository_phid = $request->getValue('repositoryPHID'); 35 + $repository = id(new PhabricatorRepositoryQuery()) 36 + ->setViewer($viewer) 37 + ->withPHIDs(array($repository_phid)) 38 + ->executeOne(); 39 + 40 + if (!$repository) { 41 + throw new Exception( 42 + pht('No repository exists with PHID "%s".', $repository_phid)); 37 43 } 38 44 39 45 $branch_name = $request->getValue('branch'); 40 46 if ($branch_name == '') { 41 47 $repository = id(new PhabricatorRepositoryQuery()) 42 48 ->setViewer($request->getUser()) 43 - ->withIDs(array($project->getRepositoryID())) 49 + ->withIDs(array($repository->getID())) 44 50 ->executeOne(); 45 51 $branch_name = $repository->getDefaultArcanistBranch(); 46 52 } 47 53 48 54 $branch = id(new PhabricatorRepositoryBranch())->loadOneWhere( 49 55 'repositoryID = %d AND name = %s', 50 - $project->getRepositoryID(), 56 + $repository->getID(), 51 57 $branch_name); 52 58 if (!$branch || !$branch->getLintCommit()) { 53 59 return array();