Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/scripts/symbols/clear_repository_symbols.php
12241 views
1
#!/usr/bin/env php
2
<?php
3
4
$root = dirname(dirname(dirname(__FILE__)));
5
require_once $root.'/scripts/__init_script__.php';
6
7
$args = new PhutilArgumentParser($argv);
8
$args->setSynopsis(<<<EOSYNOPSIS
9
**clear_repository_symbols.php** [__options__] __repository__
10
11
Clear repository symbols.
12
EOSYNOPSIS
13
);
14
$args->parseStandardArguments();
15
$args->parse(
16
array(
17
array(
18
'name' => 'repository',
19
'wildcard' => true,
20
),
21
));
22
23
$identifiers = $args->getArg('repository');
24
if (count($identifiers) !== 1) {
25
$args->printHelpAndExit();
26
}
27
28
$identifier = head($identifiers);
29
$repository = id(new PhabricatorRepositoryQuery())
30
->setViewer(PhabricatorUser::getOmnipotentUser())
31
->withIdentifiers($identifiers)
32
->executeOne();
33
34
if (!$repository) {
35
echo tsprintf(
36
"%s\n",
37
pht('Repository "%s" does not exist.', $identifier));
38
exit(1);
39
}
40
41
$input = file_get_contents('php://stdin');
42
$normalized = array();
43
foreach (explode("\n", trim($input)) as $path) {
44
// Emulate the behavior of the symbol generation scripts.
45
$normalized[] = '/'.ltrim($path, './');
46
}
47
$paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths(
48
$normalized);
49
50
$symbol = new PhabricatorRepositorySymbol();
51
$conn_w = $symbol->establishConnection('w');
52
53
foreach (array_chunk(array_values($paths), 128) as $chunk) {
54
queryfx(
55
$conn_w,
56
'DELETE FROM %T WHERE repositoryPHID = %s AND pathID IN (%Ld)',
57
$symbol->getTableName(),
58
$repository->getPHID(),
59
$chunk);
60
}
61
62