3 abstract class PhabricatorAuditManagementWorkflow
4 extends PhabricatorManagementWorkflow
{
7 protected function getCommitConstraintArguments() {
11 'help' => pht('Update all commits in all repositories.'),
16 'help' => pht('Update named commits and repositories.'),
21 protected function loadCommitsWithConstraints(PhutilArgumentParser
$args) {
22 $viewer = $this->getViewer();
24 $all = $args->getArg('all');
25 $names = $args->getArg('objects');
27 if (!$names && !$all) {
28 throw new PhutilArgumentUsageException(
30 'Specify "--all" to affect everything, or a list of specific '.
31 'commits or repositories to affect.'));
32 } else if ($names && $all) {
33 throw new PhutilArgumentUsageException(
35 'Specify either a list of objects to affect or "--all", but not '.
40 $objects = new LiskMigrationIterator(new PhabricatorRepository());
42 $query = id(new PhabricatorObjectQuery())
50 $results = $query->getNamedResults();
51 foreach ($names as $name) {
52 if (!isset($results[$name])) {
53 throw new PhutilArgumentUsageException(
55 'Object "%s" is not a valid object.',
59 $object = $results[$name];
60 if (!($object instanceof PhabricatorRepository
) &&
61 !($object instanceof PhabricatorRepositoryCommit
)) {
62 throw new PhutilArgumentUsageException(
64 'Object "%s" is not a valid repository or commit.',
75 protected function loadCommitsForConstraintObject($object) {
76 $viewer = $this->getViewer();
78 if ($object instanceof PhabricatorRepository
) {
79 $commits = id(new DiffusionCommitQuery())
81 ->withRepository($object)
84 $commits = array($object);
90 protected function synchronizeCommitAuditState($commit_phid) {
91 $viewer = $this->getViewer();
93 $commit = id(new DiffusionCommitQuery())
95 ->withPHIDs(array($commit_phid))
96 ->needAuditRequests(true)
102 $old_status = $commit->getAuditStatusObject();
103 $commit->updateAuditStatus($commit->getAudits());
104 $new_status = $commit->getAuditStatusObject();
106 if ($old_status->getKey() == $new_status->getKey()) {
110 'No synchronization changes for "%s".',
111 $commit->getDisplayName()));
116 'Synchronizing "%s": "%s" -> "%s".',
117 $commit->getDisplayName(),
118 $old_status->getName(),
119 $new_status->getName()));