mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +01:00
29d1115037
Summary: Ref T10748. This needs more extensive testing and is sure to have some rough edges, but seems to basically work so far. Throwing this up so I can work through it more deliberately and make notes. Test Plan: - Ran migration. - Used `bin/repository list` to list existing repositories. - Used `bin/repository update <repository>` to update various repositories. - Updated a migrated, hosted Git repository. - Updated a migrated, observed Git repository. - Converted an observed repository into a hosted repository by toggling the I/O mode of the URI. - Conveted a hosted repository into an observed repository by toggling it back. - Created and activated a new empty hosted Git repository. - Created and activated an observed Git repository. - Updated a mirrored repository. - Cloned and pushed over HTTP. - Tried to HTTP push a read-only repository. - Cloned and pushed over SSH. - Tried to SSH push a read-only repository. - Updated several Mercurial repositories. - Updated several Subversion repositories. - Created and edited repositories via the API. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15842
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
$table = new PhabricatorRepository();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
foreach (new LiskMigrationIterator($table) as $repository) {
|
|
$uris = array();
|
|
|
|
$serve_http = $repository->getDetail('serve-over-http');
|
|
$http_io = PhabricatorRepositoryURI::IO_DEFAULT;
|
|
$disable_http = false;
|
|
switch ($serve_http) {
|
|
case 'readwrite':
|
|
break;
|
|
case 'readonly':
|
|
$http_io = PhabricatorRepositoryURI::IO_READ;
|
|
break;
|
|
case 'off':
|
|
default:
|
|
$disable_http = true;
|
|
break;
|
|
}
|
|
|
|
$serve_ssh = $repository->getDetail('serve-over-ssh');
|
|
$ssh_io = PhabricatorRepositoryURI::IO_DEFAULT;
|
|
$disable_ssh = false;
|
|
switch ($serve_ssh) {
|
|
case 'readwrite':
|
|
break;
|
|
case 'readonly':
|
|
$ssh_io = PhabricatorRepositoryURI::IO_READ;
|
|
break;
|
|
case 'off':
|
|
default:
|
|
$disable_ssh = true;
|
|
break;
|
|
}
|
|
|
|
$uris = $repository->newBuiltinURIs();
|
|
|
|
foreach ($uris as $uri) {
|
|
$builtin_protocol = $uri->getBuiltinProtocol();
|
|
if ($builtin_protocol == PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH) {
|
|
$uri->setIsDisabled((int)$disable_ssh);
|
|
$uri->setIoType($ssh_io);
|
|
} else {
|
|
$uri->setIsDisabled((int)$disable_http);
|
|
$uri->setIoType($http_io);
|
|
}
|
|
}
|
|
|
|
if (!$repository->isHosted()) {
|
|
$remote_uri = $repository->getDetail('remote-uri');
|
|
if (strlen($remote_uri)) {
|
|
$uris[] = PhabricatorRepositoryURI::initializeNewURI()
|
|
->setRepositoryPHID($repository->getPHID())
|
|
->attachRepository($repository)
|
|
->setURI($remote_uri)
|
|
->setCredentialPHID($repository->getCredentialPHID())
|
|
->setIOType(PhabricatorRepositoryURI::IO_OBSERVE);
|
|
}
|
|
}
|
|
|
|
foreach ($uris as $uri) {
|
|
$already_exists = id(new PhabricatorRepositoryURI())->loadOneWhere(
|
|
'repositoryPHID = %s AND uri = %s LIMIT 1',
|
|
$repository->getPHID(),
|
|
$uri->getURI());
|
|
if ($already_exists) {
|
|
continue;
|
|
}
|
|
|
|
$uri->save();
|
|
|
|
echo tsprintf(
|
|
"%s\n",
|
|
pht(
|
|
'Migrated URI "%s" for repository "%s".',
|
|
$uri->getURI(),
|
|
$repository->getDisplayName()));
|
|
}
|
|
}
|