1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-21 22:32: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:
Joshua Spence 2015-05-19 00:07:46 +10:00
parent 898ce6bace
commit f8b7f03145
3 changed files with 49 additions and 26 deletions

View file

@ -17,35 +17,38 @@ $args = id(new PhutilArgumentParser($argv))
->parse(array(
array(
'name' => 'all',
'help' =>
'help' => pht(
'Discover problems in the whole repository instead of just changes '.
'since the last run.',
'since the last run.'),
),
array(
'name' => 'arc',
'param' => 'path',
'default' => 'arc',
'help' => 'Path to Arcanist executable.',
'help' => pht('Path to Arcanist executable.'),
),
array(
'name' => 'severity',
'param' => 'string',
'default' => ArcanistLintSeverity::SEVERITY_ADVICE,
'help' => 'Minimum severity, one of ArcanistLintSeverity constants.',
'help' => pht(
'Minimum severity, one of %s constants.',
'ArcanistLintSeverity'),
),
array(
'name' => 'chunk-size',
'param' => 'number',
'default' => 256,
'help' => 'Number of paths passed to `arc` at once.',
'help' => pht('Number of paths passed to `%s` at once.', 'arc'),
),
array(
'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())
->setAll($args->getArg('all', false))
@ -55,4 +58,4 @@ $count = id(new DiffusionLintSaveRunner())
->setNeedsBlame($args->getArg('blame'))
->run('.');
echo "\nProcessed {$count} files.\n";
echo "\n".pht('Processed %d files.', $count)."\n";

View file

@ -58,17 +58,31 @@ final class DiffusionLintSaveRunner {
}
}
$project_id = $working_copy->getProjectID();
$project = id(new PhabricatorRepositoryArcanistProject())
->loadOneWhere('name = %s', $project_id);
if (!$project || !$project->getRepositoryID()) {
throw new Exception("Couldn't find repository for {$project_id}.");
$callsign = $configuration_manager->getConfigFromAnySource(
'repository.callsign');
$uuid = $api->getRepositoryUUID();
$remote_uri = $api->getRemoteURI();
$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();
if (!$repository) {
throw new Exception(pht('No repository was found.'));
}
$this->branch = PhabricatorRepositoryBranch::loadOrCreateBranch(
$project->getRepositoryID(),
$repository->getID(),
$branch_name);
$this->conn = $this->branch->establishConnection('w');

View file

@ -12,15 +12,15 @@ final class DiffusionGetLintMessagesConduitAPIMethod
}
public function getMethodDescription() {
return 'Get lint messages for existing code.';
return pht('Get lint messages for existing code.');
}
protected function defineParamTypes() {
return array(
'arcanistProject' => 'required string',
'branch' => 'optional string',
'commit' => 'optional string',
'files' => 'required list<string>',
'repositoryPHID' => 'required phid',
'branch' => 'required string',
'commit' => 'optional string',
'files' => 'required list<string>',
);
}
@ -29,25 +29,31 @@ final class DiffusionGetLintMessagesConduitAPIMethod
}
protected function execute(ConduitAPIRequest $request) {
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
'name = %s',
$request->getValue('arcanistProject'));
if (!$project || !$project->getRepositoryID()) {
return array();
$viewer = $request->getUser();
$repository_phid = $request->getValue('repositoryPHID');
$repository = id(new PhabricatorRepositoryQuery())
->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');
if ($branch_name == '') {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->withIDs(array($project->getRepositoryID()))
->withIDs(array($repository->getID()))
->executeOne();
$branch_name = $repository->getDefaultArcanistBranch();
}
$branch = id(new PhabricatorRepositoryBranch())->loadOneWhere(
'repositoryID = %d AND name = %s',
$project->getRepositoryID(),
$repository->getID(),
$branch_name);
if (!$branch || !$branch->getLintCommit()) {
return array();