Page MenuHomePhabricator

D19137.diff
No OneTemporary

D19137.diff

diff --git a/src/applications/harbormaster/management/HarbormasterManagementRebuildLogWorkflow.php b/src/applications/harbormaster/management/HarbormasterManagementRebuildLogWorkflow.php
--- a/src/applications/harbormaster/management/HarbormasterManagementRebuildLogWorkflow.php
+++ b/src/applications/harbormaster/management/HarbormasterManagementRebuildLogWorkflow.php
@@ -6,7 +6,10 @@
protected function didConstruct() {
$this
->setName('rebuild-log')
- ->setExamples('**rebuild-log** --id __id__ [__options__]')
+ ->setExamples(
+ pht(
+ "**rebuild-log** --id __id__ [__options__]\n".
+ "**rebuild-log** --all"))
->setSynopsis(
pht(
'Rebuild the file and summary for a log. This is primarily '.
@@ -18,31 +21,76 @@
'param' => 'id',
'help' => pht('Log to rebuild.'),
),
+ array(
+ 'name' => 'all',
+ 'help' => pht('Rebuild all logs.'),
+ ),
+ array(
+ 'name' => 'force',
+ 'help' => pht(
+ 'Force logs to rebuild even if they appear to be in good '.
+ 'shape already.'),
+ ),
));
}
public function execute(PhutilArgumentParser $args) {
$viewer = $this->getViewer();
+ $is_force = $args->getArg('force');
+
$log_id = $args->getArg('id');
- if (!$log_id) {
+ $is_all = $args->getArg('all');
+
+ if (!$is_all && !$log_id) {
throw new PhutilArgumentUsageException(
- pht('Choose a build log to rebuild with "--id".'));
+ pht(
+ 'Choose a build log to rebuild with "--id", or rebuild all '.
+ 'logs with "--all".'));
}
- $log = id(new HarbormasterBuildLogQuery())
- ->setViewer($viewer)
- ->withIDs(array($log_id))
- ->executeOne();
- if (!$log) {
+ if ($is_all && $log_id) {
throw new PhutilArgumentUsageException(
pht(
- 'Unable to load build log "%s".',
- $log_id));
+ 'You can not specify both "--id" and "--all". Choose one or '.
+ 'the other.'));
+ }
+
+ if ($log_id) {
+ $log = id(new HarbormasterBuildLogQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($log_id))
+ ->executeOne();
+ if (!$log) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Unable to load build log "%s".',
+ $log_id));
+ }
+ $logs = array($log);
+ } else {
+ $logs = new LiskMigrationIterator(new HarbormasterBuildLog());
}
PhabricatorWorker::setRunAllTasksInProcess(true);
- $log->scheduleRebuild(true);
+
+ foreach ($logs as $log) {
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'Rebuilding log "%s"...',
+ pht('Build Log %d', $log->getID())));
+
+ try {
+ $log->scheduleRebuild($is_force);
+ } catch (Exception $ex) {
+ if ($is_all) {
+ phlog($ex);
+ } else {
+ throw $ex;
+ }
+ }
+ }
echo tsprintf(
"%s\n",

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 22, 9:48 AM (5 h, 21 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7029067
Default Alt Text
D19137.diff (3 KB)

Event Timeline