@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.

Allow "bin/repository thaw" to accept "--all-repositories" instead of a list of repositories

Summary:
Ref T13222. See PHI992. If you've lost an entire cluster (or have lost a device and are willing to make broad assumptions about the state the device was in) you currently have to `xargs` to thaw everything or do something else creative.

Since this workflow is broadly reasonable, provide an easier way to accomplish the goal.

Test Plan:
- Ran with `--all-repositories`, a list of repositories, both (error) and neither (error).
- Saw a helpful new list of affected repositories.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13222

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

+60 -6
+60 -6
src/applications/repository/management/PhabricatorRepositoryManagementThawWorkflow.php
··· 33 33 'help' => pht('Run operations without asking for confirmation.'), 34 34 ), 35 35 array( 36 + 'name' => 'all-repositories', 37 + 'help' => pht( 38 + 'Apply the promotion or demotion to all repositories hosted '. 39 + 'on the device.'), 40 + ), 41 + array( 36 42 'name' => 'repositories', 37 43 'wildcard' => true, 38 44 ), ··· 41 47 42 48 public function execute(PhutilArgumentParser $args) { 43 49 $viewer = $this->getViewer(); 44 - 45 - $repositories = $this->loadRepositories($args, 'repositories'); 46 - if (!$repositories) { 47 - throw new PhutilArgumentUsageException( 48 - pht('Specify one or more repositories to thaw.')); 49 - } 50 50 51 51 $promote = $args->getArg('promote'); 52 52 $demote = $args->getArg('demote'); ··· 71 71 throw new PhutilArgumentUsageException( 72 72 pht('No device "%s" exists.', $device_name)); 73 73 } 74 + 75 + $repository_names = $args->getArg('repositories'); 76 + $all_repositories = $args->getArg('all-repositories'); 77 + if ($repository_names && $all_repositories) { 78 + throw new PhutilArgumentUsageException( 79 + pht( 80 + 'Specify a list of repositories or "--all-repositories", '. 81 + 'but not both.')); 82 + } else if (!$repository_names && !$all_repositories) { 83 + throw new PhutilArgumentUsageException( 84 + pht( 85 + 'Select repositories to affect by providing a list of repositories '. 86 + 'or using the "--all-repositories" flag.')); 87 + } 88 + 89 + if ($repository_names) { 90 + $repositories = $this->loadRepositories($args, 'repositories'); 91 + if (!$repositories) { 92 + throw new PhutilArgumentUsageException( 93 + pht('Specify one or more repositories to thaw.')); 94 + } 95 + } else { 96 + $repositories = array(); 97 + 98 + $services = id(new AlmanacServiceQuery()) 99 + ->setViewer($viewer) 100 + ->withDevicePHIDs(array($device->getPHID())) 101 + ->execute(); 102 + if ($services) { 103 + $repositories = id(new PhabricatorRepositoryQuery()) 104 + ->setViewer($viewer) 105 + ->withAlmanacServicePHIDs(mpull($services, 'getPHID')) 106 + ->execute(); 107 + } 108 + 109 + if (!$repositories) { 110 + throw new PhutilArgumentUsageException( 111 + pht('There are no repositories on the selected device.')); 112 + } 113 + } 114 + 115 + $display_list = new PhutilConsoleList(); 116 + foreach ($repositories as $repository) { 117 + $display_list->addItem( 118 + pht( 119 + '%s %s', 120 + $repository->getMonogram(), 121 + $repository->getName())); 122 + } 123 + 124 + echo tsprintf( 125 + "%s\n\n%B\n", 126 + pht('These repositories will be thawed:'), 127 + $display_list->drawConsoleString()); 74 128 75 129 if ($promote) { 76 130 $risk_message = pht(