@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add "--all" and an explicit "--force" flag to `bin/harbormaster rebuild-log`

Summary: Depends on D19136. Ref T13088. Since it's probably impractical to do all the migrations these changes imply during `bin/storage upgrade`, provide some support for performing them online.

Test Plan: Ran `bin/harbormaster rebuild-log` with `--all`, `--id`, and with and without `--force`.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

Differential Revision: https://secure.phabricator.com/D19137

+59 -11
+59 -11
src/applications/harbormaster/management/HarbormasterManagementRebuildLogWorkflow.php
··· 6 6 protected function didConstruct() { 7 7 $this 8 8 ->setName('rebuild-log') 9 - ->setExamples('**rebuild-log** --id __id__ [__options__]') 9 + ->setExamples( 10 + pht( 11 + "**rebuild-log** --id __id__ [__options__]\n". 12 + "**rebuild-log** --all")) 10 13 ->setSynopsis( 11 14 pht( 12 15 'Rebuild the file and summary for a log. This is primarily '. ··· 18 21 'param' => 'id', 19 22 'help' => pht('Log to rebuild.'), 20 23 ), 24 + array( 25 + 'name' => 'all', 26 + 'help' => pht('Rebuild all logs.'), 27 + ), 28 + array( 29 + 'name' => 'force', 30 + 'help' => pht( 31 + 'Force logs to rebuild even if they appear to be in good '. 32 + 'shape already.'), 33 + ), 21 34 )); 22 35 } 23 36 24 37 public function execute(PhutilArgumentParser $args) { 25 38 $viewer = $this->getViewer(); 26 39 40 + $is_force = $args->getArg('force'); 41 + 27 42 $log_id = $args->getArg('id'); 28 - if (!$log_id) { 43 + $is_all = $args->getArg('all'); 44 + 45 + if (!$is_all && !$log_id) { 29 46 throw new PhutilArgumentUsageException( 30 - pht('Choose a build log to rebuild with "--id".')); 47 + pht( 48 + 'Choose a build log to rebuild with "--id", or rebuild all '. 49 + 'logs with "--all".')); 31 50 } 32 51 33 - $log = id(new HarbormasterBuildLogQuery()) 34 - ->setViewer($viewer) 35 - ->withIDs(array($log_id)) 36 - ->executeOne(); 37 - if (!$log) { 52 + if ($is_all && $log_id) { 38 53 throw new PhutilArgumentUsageException( 39 54 pht( 40 - 'Unable to load build log "%s".', 41 - $log_id)); 55 + 'You can not specify both "--id" and "--all". Choose one or '. 56 + 'the other.')); 57 + } 58 + 59 + if ($log_id) { 60 + $log = id(new HarbormasterBuildLogQuery()) 61 + ->setViewer($viewer) 62 + ->withIDs(array($log_id)) 63 + ->executeOne(); 64 + if (!$log) { 65 + throw new PhutilArgumentUsageException( 66 + pht( 67 + 'Unable to load build log "%s".', 68 + $log_id)); 69 + } 70 + $logs = array($log); 71 + } else { 72 + $logs = new LiskMigrationIterator(new HarbormasterBuildLog()); 42 73 } 43 74 44 75 PhabricatorWorker::setRunAllTasksInProcess(true); 45 - $log->scheduleRebuild(true); 76 + 77 + foreach ($logs as $log) { 78 + echo tsprintf( 79 + "%s\n", 80 + pht( 81 + 'Rebuilding log "%s"...', 82 + pht('Build Log %d', $log->getID()))); 83 + 84 + try { 85 + $log->scheduleRebuild($is_force); 86 + } catch (Exception $ex) { 87 + if ($is_all) { 88 + phlog($ex); 89 + } else { 90 + throw $ex; 91 + } 92 + } 93 + } 46 94 47 95 echo tsprintf( 48 96 "%s\n",