1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 00:38:51 +02:00

Update import/clear symbols scripts for callsigns

Summary: Ref T4245. Accept identifiers instead of callsigns in these scripts so things continue to work in a future callsign-optional world.

Test Plan: Ran these scripts with both valid and invalid arguments; saw success and errors.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D15300
This commit is contained in:
epriestley 2016-02-18 03:09:59 -08:00
parent f557fc9caa
commit 78fba426f6
2 changed files with 18 additions and 14 deletions

View file

@ -6,7 +6,7 @@ require_once $root.'/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**clear_repository_symbols.php** [__options__] __callsign__
**clear_repository_symbols.php** [__options__] __repository__
Clear repository symbols.
EOSYNOPSIS
@ -15,24 +15,26 @@ $args->parseStandardArguments();
$args->parse(
array(
array(
'name' => 'callsign',
'name' => 'repository',
'wildcard' => true,
),
));
$callsigns = $args->getArg('callsign');
if (count($callsigns) !== 1) {
$identifiers = $args->getArg('repository');
if (count($identifiers) !== 1) {
$args->printHelpAndExit();
}
$callsign = head($callsigns);
$identifier = head($identifiers);
$repository = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withCallsigns($callsigns)
->withIdentifiers($identifiers)
->executeOne();
if (!$repository) {
echo pht("Repository '%s' does not exist.", $callsign);
echo tsprintf(
"%s\n",
pht('Repository "%s" does not exist.', $identifier));
exit(1);
}

View file

@ -6,7 +6,7 @@ require_once $root.'/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**import_repository_symbols.php** [__options__] __callsign__ < symbols
**import_repository_symbols.php** [__options__] __repository__ < symbols
Import repository symbols (symbols are read from stdin).
EOSYNOPSIS
@ -35,24 +35,26 @@ $args->parse(
'be part of a single transaction.'),
),
array(
'name' => 'callsign',
'name' => 'repository',
'wildcard' => true,
),
));
$callsigns = $args->getArg('callsign');
if (count($callsigns) !== 1) {
$identifiers = $args->getArg('repository');
if (count($identifiers) !== 1) {
$args->printHelpAndExit();
}
$callsign = head($callsigns);
$identifier = head($identifiers);
$repository = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withCallsigns($callsigns)
->withIdentifiers($identifiers)
->executeOne();
if (!$repository) {
echo pht("Repository '%s' does not exist.", $callsign);
echo tsprintf(
"%s\n",
pht('Repository "%s" does not exist.', $identifier));
exit(1);
}