mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 20:52:43 +01:00
42eaa88f80
Summary: Ref T10748. This migrates and swaps mirroring to `PhabricatorRepositoryURI`, obsoleting `PhabricatorRepositoryMirror`. This prevents you from editing, adding or disabling mirrors unless you know a secret URI (until the UI cuts over fully), but existing mirroring is not affected. Test Plan: - Added a mirroring URI to an old repository. - Verified it worked with `bin/repository mirror`. - Migrated forward. - Verified it still worked with `bin/repository mirror`. - Wow, mirroring: https://github.com/epriestley/locktopia-mirror Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15841
38 lines
959 B
PHP
38 lines
959 B
PHP
<?php
|
|
|
|
$table = new PhabricatorRepository();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
$mirrors = queryfx_all(
|
|
$conn_w,
|
|
'SELECT * FROM %T',
|
|
'repository_mirror');
|
|
|
|
foreach ($mirrors as $mirror) {
|
|
$repository_phid = $mirror['repositoryPHID'];
|
|
$uri = $mirror['remoteURI'];
|
|
|
|
$already_exists = id(new PhabricatorRepositoryURI())->loadOneWhere(
|
|
'repositoryPHID = %s AND uri = %s',
|
|
$repository_phid,
|
|
$uri);
|
|
if ($already_exists) {
|
|
// Decline to migrate stuff that looks like it was already migrated.
|
|
continue;
|
|
}
|
|
|
|
$new_uri = PhabricatorRepositoryURI::initializeNewURI()
|
|
->setIOType(PhabricatorRepositoryURI::IO_MIRROR)
|
|
->setRepositoryPHID($repository_phid)
|
|
->setURI($uri)
|
|
->setCredentialPHID($mirror['credentialPHID'])
|
|
->setDateCreated($mirror['dateCreated'])
|
|
->setDateModified($mirror['dateModified'])
|
|
->save();
|
|
|
|
echo tsprintf(
|
|
"%s\n",
|
|
pht(
|
|
'Migrated mirror "%s".',
|
|
$uri));
|
|
}
|