mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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
This commit is contained in:
parent
898ce6bace
commit
f8b7f03145
3 changed files with 49 additions and 26 deletions
|
@ -17,35 +17,38 @@ $args = id(new PhutilArgumentParser($argv))
|
||||||
->parse(array(
|
->parse(array(
|
||||||
array(
|
array(
|
||||||
'name' => 'all',
|
'name' => 'all',
|
||||||
'help' =>
|
'help' => pht(
|
||||||
'Discover problems in the whole repository instead of just changes '.
|
'Discover problems in the whole repository instead of just changes '.
|
||||||
'since the last run.',
|
'since the last run.'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'arc',
|
'name' => 'arc',
|
||||||
'param' => 'path',
|
'param' => 'path',
|
||||||
'default' => 'arc',
|
'default' => 'arc',
|
||||||
'help' => 'Path to Arcanist executable.',
|
'help' => pht('Path to Arcanist executable.'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'severity',
|
'name' => 'severity',
|
||||||
'param' => 'string',
|
'param' => 'string',
|
||||||
'default' => ArcanistLintSeverity::SEVERITY_ADVICE,
|
'default' => ArcanistLintSeverity::SEVERITY_ADVICE,
|
||||||
'help' => 'Minimum severity, one of ArcanistLintSeverity constants.',
|
'help' => pht(
|
||||||
|
'Minimum severity, one of %s constants.',
|
||||||
|
'ArcanistLintSeverity'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'chunk-size',
|
'name' => 'chunk-size',
|
||||||
'param' => 'number',
|
'param' => 'number',
|
||||||
'default' => 256,
|
'default' => 256,
|
||||||
'help' => 'Number of paths passed to `arc` at once.',
|
'help' => pht('Number of paths passed to `%s` at once.', 'arc'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'blame',
|
'name' => 'blame',
|
||||||
'help' => 'Assign lint errors to authors who last modified the line.',
|
'help' => pht(
|
||||||
|
'Assign lint errors to authors who last modified the line.'),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Saving lint errors to database...\n";
|
echo pht('Saving lint errors to database...')."\n";
|
||||||
|
|
||||||
$count = id(new DiffusionLintSaveRunner())
|
$count = id(new DiffusionLintSaveRunner())
|
||||||
->setAll($args->getArg('all', false))
|
->setAll($args->getArg('all', false))
|
||||||
|
@ -55,4 +58,4 @@ $count = id(new DiffusionLintSaveRunner())
|
||||||
->setNeedsBlame($args->getArg('blame'))
|
->setNeedsBlame($args->getArg('blame'))
|
||||||
->run('.');
|
->run('.');
|
||||||
|
|
||||||
echo "\nProcessed {$count} files.\n";
|
echo "\n".pht('Processed %d files.', $count)."\n";
|
||||||
|
|
|
@ -58,17 +58,31 @@ final class DiffusionLintSaveRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$project_id = $working_copy->getProjectID();
|
$callsign = $configuration_manager->getConfigFromAnySource(
|
||||||
$project = id(new PhabricatorRepositoryArcanistProject())
|
'repository.callsign');
|
||||||
->loadOneWhere('name = %s', $project_id);
|
$uuid = $api->getRepositoryUUID();
|
||||||
if (!$project || !$project->getRepositoryID()) {
|
$remote_uri = $api->getRemoteURI();
|
||||||
throw new Exception("Couldn't find repository for {$project_id}.");
|
|
||||||
|
$repository_query = id(new PhabricatorRepositoryQuery())
|
||||||
|
->setViewer(PhabricatorUser::getOmnipotentUser());
|
||||||
|
|
||||||
|
if ($callsign) {
|
||||||
|
$repository_query->withCallsigns(array($callsign));
|
||||||
|
} else if ($uuid) {
|
||||||
|
$repository_query->withUUIDs(array($uuid));
|
||||||
|
} else if ($remote_uri) {
|
||||||
|
$repository_query->withRemoteURIs(array($remote_uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$repository = $repository_query->executeOne();
|
||||||
$branch_name = $api->getBranchName();
|
$branch_name = $api->getBranchName();
|
||||||
|
|
||||||
|
if (!$repository) {
|
||||||
|
throw new Exception(pht('No repository was found.'));
|
||||||
|
}
|
||||||
|
|
||||||
$this->branch = PhabricatorRepositoryBranch::loadOrCreateBranch(
|
$this->branch = PhabricatorRepositoryBranch::loadOrCreateBranch(
|
||||||
$project->getRepositoryID(),
|
$repository->getID(),
|
||||||
$branch_name);
|
$branch_name);
|
||||||
$this->conn = $this->branch->establishConnection('w');
|
$this->conn = $this->branch->establishConnection('w');
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ final class DiffusionGetLintMessagesConduitAPIMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMethodDescription() {
|
public function getMethodDescription() {
|
||||||
return 'Get lint messages for existing code.';
|
return pht('Get lint messages for existing code.');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function defineParamTypes() {
|
protected function defineParamTypes() {
|
||||||
return array(
|
return array(
|
||||||
'arcanistProject' => 'required string',
|
'repositoryPHID' => 'required phid',
|
||||||
'branch' => 'optional string',
|
'branch' => 'required string',
|
||||||
'commit' => 'optional string',
|
'commit' => 'optional string',
|
||||||
'files' => 'required list<string>',
|
'files' => 'required list<string>',
|
||||||
);
|
);
|
||||||
|
@ -29,25 +29,31 @@ final class DiffusionGetLintMessagesConduitAPIMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
|
$viewer = $request->getUser();
|
||||||
'name = %s',
|
|
||||||
$request->getValue('arcanistProject'));
|
$repository_phid = $request->getValue('repositoryPHID');
|
||||||
if (!$project || !$project->getRepositoryID()) {
|
$repository = id(new PhabricatorRepositoryQuery())
|
||||||
return array();
|
->setViewer($viewer)
|
||||||
|
->withPHIDs(array($repository_phid))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
if (!$repository) {
|
||||||
|
throw new Exception(
|
||||||
|
pht('No repository exists with PHID "%s".', $repository_phid));
|
||||||
}
|
}
|
||||||
|
|
||||||
$branch_name = $request->getValue('branch');
|
$branch_name = $request->getValue('branch');
|
||||||
if ($branch_name == '') {
|
if ($branch_name == '') {
|
||||||
$repository = id(new PhabricatorRepositoryQuery())
|
$repository = id(new PhabricatorRepositoryQuery())
|
||||||
->setViewer($request->getUser())
|
->setViewer($request->getUser())
|
||||||
->withIDs(array($project->getRepositoryID()))
|
->withIDs(array($repository->getID()))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
$branch_name = $repository->getDefaultArcanistBranch();
|
$branch_name = $repository->getDefaultArcanistBranch();
|
||||||
}
|
}
|
||||||
|
|
||||||
$branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(
|
$branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(
|
||||||
'repositoryID = %d AND name = %s',
|
'repositoryID = %d AND name = %s',
|
||||||
$project->getRepositoryID(),
|
$repository->getID(),
|
||||||
$branch_name);
|
$branch_name);
|
||||||
if (!$branch || !$branch->getLintCommit()) {
|
if (!$branch || !$branch->getLintCommit()) {
|
||||||
return array();
|
return array();
|
||||||
|
|
Loading…
Reference in a new issue