|
1 | 1 | #!/usr/bin/env php |
2 | 2 | <?php |
3 | 3 |
|
4 | | -$root = dirname(dirname(dirname(__FILE__))); |
5 | | -require_once $root.'/scripts/__init_script__.php'; |
6 | | - |
7 | | -$args = new PhutilArgumentParser($argv); |
8 | | -$args->setTagline('manage open Audit requests'); |
9 | | -$args->setSynopsis(<<<EOSYNOPSIS |
10 | | -**audit.php** __repository_callsign__ |
11 | | - Close all open audit requests in a repository. This is intended to |
12 | | - reset the state of an imported repository which triggered a bunch of |
13 | | - spurious audit requests during import. |
14 | | -
|
15 | | -EOSYNOPSIS |
16 | | - ); |
17 | | -$args->parseStandardArguments(); |
18 | | -$args->parse( |
19 | | - array( |
20 | | - array( |
21 | | - 'name' => 'more', |
22 | | - 'wildcard' => true, |
23 | | - ), |
24 | | - )); |
25 | | - |
26 | | -$more = $args->getArg('more'); |
27 | | -if (count($more) !== 1) { |
28 | | - $args->printHelpAndExit(); |
29 | | -} |
30 | | -$callsign = reset($more); |
31 | | - |
32 | | -$repository = id(new PhabricatorRepository())->loadOneWhere( |
33 | | - 'callsign = %s', |
34 | | - $callsign); |
35 | | -if (!$repository) { |
36 | | - throw new Exception("No repository exists with callsign '{$callsign}'!"); |
37 | | -} |
38 | | - |
39 | | -$ok = phutil_console_confirm( |
40 | | - 'This will reset all open audit requests ("Audit Required" or "Concern '. |
41 | | - 'Raised") for commits in this repository to "Audit Not Required". This '. |
42 | | - 'operation destroys information and can not be undone! Are you sure '. |
43 | | - 'you want to proceed?'); |
44 | | -if (!$ok) { |
45 | | - echo "OK, aborting.\n"; |
46 | | - die(1); |
47 | | -} |
48 | | - |
49 | | -echo "Loading commits...\n"; |
50 | | -$all_commits = id(new PhabricatorRepositoryCommit())->loadAllWhere( |
51 | | - 'repositoryID = %d', |
52 | | - $repository->getID()); |
53 | | - |
54 | | -echo "Clearing audit requests...\n"; |
55 | | - |
56 | | -foreach ($all_commits as $commit) { |
57 | | - $query = id(new PhabricatorAuditQuery()) |
58 | | - ->withStatus(PhabricatorAuditQuery::STATUS_OPEN) |
59 | | - ->withCommitPHIDs(array($commit->getPHID())); |
60 | | - $requests = $query->execute(); |
61 | | - |
62 | | - echo "Clearing ".$commit->getPHID()."... "; |
63 | | - |
64 | | - if (!$requests) { |
65 | | - echo "nothing to do.\n"; |
66 | | - continue; |
67 | | - } else { |
68 | | - echo count($requests)." requests to clear"; |
69 | | - } |
70 | | - |
71 | | - foreach ($requests as $request) { |
72 | | - $request->setAuditStatus( |
73 | | - PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED); |
74 | | - $request->save(); |
75 | | - echo "."; |
76 | | - } |
77 | | - |
78 | | - $commit->setAuditStatus(PhabricatorAuditCommitStatusConstants::NONE); |
79 | | - $commit->save(); |
80 | | - echo "\n"; |
81 | | -} |
82 | | - |
83 | | -echo "Done.\n"; |
| 4 | +echo "This script has been replaced with `bin/audit`.\n"; |
| 5 | +exit(1); |
0 commit comments