mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Allow editing hosting policies via command line
Summary: Exposes the serve-over-http and serve-over-ssh options for a repository to the `bin/repository edit` endpoint. Test Plan: Ran `bin/repository` with the new options over several hundred repos Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, chasemp, 20after4, epriestley Differential Revision: https://secure.phabricator.com/D14250
This commit is contained in:
parent
262d7b7780
commit
e80970eba0
1 changed files with 35 additions and 1 deletions
|
@ -7,7 +7,10 @@ final class PhabricatorRepositoryManagementEditWorkflow
|
|||
$this
|
||||
->setName('edit')
|
||||
->setExamples('**edit** --as __username__ __repository__ ...')
|
||||
->setSynopsis(pht('Edit __repository__, named by callsign.'))
|
||||
->setSynopsis(
|
||||
pht(
|
||||
'Edit __repository__, named by callsign '.
|
||||
'(will eventually be deprecated by Conduit).'))
|
||||
->setArguments(
|
||||
array(
|
||||
array(
|
||||
|
@ -24,6 +27,16 @@ final class PhabricatorRepositoryManagementEditWorkflow
|
|||
'param' => 'path',
|
||||
'help' => pht('Edit the local path.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'serve-http',
|
||||
'param' => 'string',
|
||||
'help' => pht('Edit the http serving policy.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'serve-ssh',
|
||||
'param' => 'string',
|
||||
'help' => pht('Edit the ssh serving policy.'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -68,12 +81,33 @@ final class PhabricatorRepositoryManagementEditWorkflow
|
|||
$xactions = array();
|
||||
|
||||
$type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
|
||||
$type_protocol_http =
|
||||
PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP;
|
||||
$type_protocol_ssh = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_SSH;
|
||||
$allowed_serve_modes = array(
|
||||
PhabricatorRepository::SERVE_OFF,
|
||||
PhabricatorRepository::SERVE_READONLY,
|
||||
PhabricatorRepository::SERVE_READWRITE,
|
||||
);
|
||||
|
||||
if ($args->getArg('local-path')) {
|
||||
$xactions[] = id(new PhabricatorRepositoryTransaction())
|
||||
->setTransactionType($type_local_path)
|
||||
->setNewValue($args->getArg('local-path'));
|
||||
}
|
||||
$serve_http = $args->getArg('serve-http');
|
||||
if ($serve_http && in_array($serve_http, $allowed_serve_modes)) {
|
||||
$xactions[] = id(new PhabricatorRepositoryTransaction())
|
||||
->setTransactionType($type_protocol_http)
|
||||
->setNewValue($serve_http);
|
||||
}
|
||||
$serve_ssh = $args->getArg('serve-ssh');
|
||||
if ($serve_ssh && in_array($serve_ssh, $allowed_serve_modes)) {
|
||||
$xactions[] = id(new PhabricatorRepositoryTransaction())
|
||||
->setTransactionType($type_protocol_ssh)
|
||||
->setNewValue($serve_ssh);
|
||||
}
|
||||
|
||||
|
||||
if (!$xactions) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
|
|
Loading…
Reference in a new issue