1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00

Make bin/diviner generate --repository <repository> accept identifiers

Summary: Ref T4245. This currently accepts only callsigns; prepare it for the bright new callsign-optional world.

Test Plan:
  - Ran `./bin/diviner generate --repository 1 --book src/docs/book/flavor.book --clean`, got a good result.
  - Ran `./bin/diviner generate --repository 239238 --book src/docs/book/flavor.book --clean`, got an appropraite error about a bad repository identifier.

Reviewers: chad, avivey

Reviewed By: avivey

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D15296
This commit is contained in:
epriestley 2016-02-17 17:20:15 -08:00
parent 93d7b01222
commit 097bcb3970

View file

@ -27,7 +27,7 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow {
), ),
array( array(
'name' => 'repository', 'name' => 'repository',
'param' => 'callsign', 'param' => 'identifier',
'help' => pht('Repository that the documentation belongs to.'), 'help' => pht('Repository that the documentation belongs to.'),
), ),
)); ));
@ -192,19 +192,19 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow {
} }
$publisher = newv($publisher_class, array()); $publisher = newv($publisher_class, array());
$callsign = $args->getArg('repository'); $identifier = $args->getArg('repository');
$repository = null; $repository = null;
if ($callsign) { if (strlen($identifier)) {
$repository = id(new PhabricatorRepositoryQuery()) $repository = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser()) ->setViewer(PhabricatorUser::getOmnipotentUser())
->withCallsigns(array($callsign)) ->withIdentifiers(array($identifier))
->executeOne(); ->executeOne();
if (!$repository) { if (!$repository) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(
pht( pht(
"Repository '%s' does not exist.", 'Repository "%s" does not exist.',
$callsign)); $identifier));
} }
$publisher->setRepositoryPHID($repository->getPHID()); $publisher->setRepositoryPHID($repository->getPHID());