Changeset View
Changeset View
Standalone View
Standalone View
scripts/symbols/clear_repository_symbols.php
| #!/usr/bin/env php | #!/usr/bin/env php | ||||
| <?php | <?php | ||||
| $root = dirname(dirname(dirname(__FILE__))); | $root = dirname(dirname(dirname(__FILE__))); | ||||
| require_once $root.'/scripts/__init_script__.php'; | require_once $root.'/scripts/__init_script__.php'; | ||||
| $args = new PhutilArgumentParser($argv); | $args = new PhutilArgumentParser($argv); | ||||
| $args->setSynopsis(<<<EOSYNOPSIS | $args->setSynopsis(<<<EOSYNOPSIS | ||||
| **clear_repository_symbols.php** [__options__] __callsign__ | **clear_repository_symbols.php** [__options__] __repository__ | ||||
| Clear repository symbols. | Clear repository symbols. | ||||
| EOSYNOPSIS | EOSYNOPSIS | ||||
| ); | ); | ||||
| $args->parseStandardArguments(); | $args->parseStandardArguments(); | ||||
| $args->parse( | $args->parse( | ||||
| array( | array( | ||||
| array( | array( | ||||
| 'name' => 'callsign', | 'name' => 'repository', | ||||
| 'wildcard' => true, | 'wildcard' => true, | ||||
| ), | ), | ||||
| )); | )); | ||||
| $callsigns = $args->getArg('callsign'); | $identifiers = $args->getArg('repository'); | ||||
| if (count($callsigns) !== 1) { | if (count($identifiers) !== 1) { | ||||
| $args->printHelpAndExit(); | $args->printHelpAndExit(); | ||||
| } | } | ||||
| $callsign = head($callsigns); | $identifier = head($identifiers); | ||||
| $repository = id(new PhabricatorRepositoryQuery()) | $repository = id(new PhabricatorRepositoryQuery()) | ||||
| ->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
| ->withCallsigns($callsigns) | ->withIdentifiers($identifiers) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$repository) { | if (!$repository) { | ||||
| echo pht("Repository '%s' does not exist.", $callsign); | echo tsprintf( | ||||
| "%s\n", | |||||
| pht('Repository "%s" does not exist.', $identifier)); | |||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| $input = file_get_contents('php://stdin'); | $input = file_get_contents('php://stdin'); | ||||
| $normalized = array(); | $normalized = array(); | ||||
| foreach (explode("\n", trim($input)) as $path) { | foreach (explode("\n", trim($input)) as $path) { | ||||
| // Emulate the behavior of the symbol generation scripts. | // Emulate the behavior of the symbol generation scripts. | ||||
| $normalized[] = '/'.ltrim($path, './'); | $normalized[] = '/'.ltrim($path, './'); | ||||
| Show All 15 Lines | |||||