Path: blob/master/scripts/symbols/clear_repository_symbols.php
12241 views
#!/usr/bin/env php1<?php23$root = dirname(dirname(dirname(__FILE__)));4require_once $root.'/scripts/__init_script__.php';56$args = new PhutilArgumentParser($argv);7$args->setSynopsis(<<<EOSYNOPSIS8**clear_repository_symbols.php** [__options__] __repository__910Clear repository symbols.11EOSYNOPSIS12);13$args->parseStandardArguments();14$args->parse(15array(16array(17'name' => 'repository',18'wildcard' => true,19),20));2122$identifiers = $args->getArg('repository');23if (count($identifiers) !== 1) {24$args->printHelpAndExit();25}2627$identifier = head($identifiers);28$repository = id(new PhabricatorRepositoryQuery())29->setViewer(PhabricatorUser::getOmnipotentUser())30->withIdentifiers($identifiers)31->executeOne();3233if (!$repository) {34echo tsprintf(35"%s\n",36pht('Repository "%s" does not exist.', $identifier));37exit(1);38}3940$input = file_get_contents('php://stdin');41$normalized = array();42foreach (explode("\n", trim($input)) as $path) {43// Emulate the behavior of the symbol generation scripts.44$normalized[] = '/'.ltrim($path, './');45}46$paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths(47$normalized);4849$symbol = new PhabricatorRepositorySymbol();50$conn_w = $symbol->establishConnection('w');5152foreach (array_chunk(array_values($paths), 128) as $chunk) {53queryfx(54$conn_w,55'DELETE FROM %T WHERE repositoryPHID = %s AND pathID IN (%Ld)',56$symbol->getTableName(),57$repository->getPHID(),58$chunk);59}606162