2017-01-31 17:52:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorAuditSynchronizeManagementWorkflow
|
|
|
|
extends PhabricatorAuditManagementWorkflow {
|
|
|
|
|
|
|
|
protected function didConstruct() {
|
|
|
|
$this
|
|
|
|
->setName('synchronize')
|
|
|
|
->setExamples('**synchronize** ...')
|
|
|
|
->setSynopsis(pht('Update audit status for commits.'))
|
|
|
|
->setArguments(
|
|
|
|
array_merge(
|
|
|
|
$this->getCommitConstraintArguments(),
|
|
|
|
array()));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$objects = $this->loadCommitsWithConstraints($args);
|
|
|
|
|
|
|
|
foreach ($objects as $object) {
|
|
|
|
$commits = $this->loadCommitsForConstraintObject($object);
|
|
|
|
foreach ($commits as $commit) {
|
|
|
|
$commit = id(new DiffusionCommitQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs(array($commit->getPHID()))
|
|
|
|
->needAuditRequests(true)
|
|
|
|
->executeOne();
|
|
|
|
if (!$commit) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-07 17:30:18 +02:00
|
|
|
$old_status = $commit->getAuditStatusObject();
|
2017-01-31 17:52:38 +01:00
|
|
|
$commit->updateAuditStatus($commit->getAudits());
|
2018-09-07 17:30:18 +02:00
|
|
|
$new_status = $commit->getAuditStatusObject();
|
2017-01-31 17:52:38 +01:00
|
|
|
|
2018-09-07 17:30:18 +02:00
|
|
|
if ($old_status->getKey() == $new_status->getKey()) {
|
2017-01-31 17:52:38 +01:00
|
|
|
echo tsprintf(
|
|
|
|
"%s\n",
|
|
|
|
pht(
|
|
|
|
'No changes for "%s".',
|
|
|
|
$commit->getDisplayName()));
|
|
|
|
} else {
|
|
|
|
echo tsprintf(
|
|
|
|
"%s\n",
|
|
|
|
pht(
|
2017-01-31 21:03:15 +01:00
|
|
|
'Updating "%s": "%s" -> "%s".',
|
2017-01-31 17:52:38 +01:00
|
|
|
$commit->getDisplayName(),
|
2018-09-07 17:30:18 +02:00
|
|
|
$old_status->getName(),
|
|
|
|
$new_status->getName()));
|
2017-01-31 21:03:15 +01:00
|
|
|
|
|
|
|
$commit->save();
|
2017-01-31 17:52:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|