1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Fix an issue with repository credential migration for older repositories

Summary: See IRC. It's possible to have a functional repository with the SSH username only in the URL. Look there if the username property isn't set. These should all be older repostiories.

Test Plan: Did a `--force --apply` upgrade.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D7665
This commit is contained in:
epriestley 2013-11-27 11:09:07 -08:00
parent 8af2f0d755
commit 04b099d9ba

View file

@ -14,13 +14,13 @@ foreach (new LiskMigrationIterator($table) as $repository) {
continue; continue;
} }
$uri = $repository->getRemoteURI(); $raw_uri = $repository->getRemoteURI();
if (!$uri) { if (!$raw_uri) {
echo "...no remote URI.\n"; echo "...no remote URI.\n";
continue; continue;
} }
$uri = new PhutilURI($uri); $uri = new PhutilURI($raw_uri);
$proto = strtolower($uri->getProtocol()); $proto = strtolower($uri->getProtocol());
if ($proto == 'http' || $proto == 'https' || $proto == 'svn') { if ($proto == 'http' || $proto == 'https' || $proto == 'svn') {
@ -29,6 +29,16 @@ foreach (new LiskMigrationIterator($table) as $repository) {
$type = PassphraseCredentialTypePassword::CREDENTIAL_TYPE; $type = PassphraseCredentialTypePassword::CREDENTIAL_TYPE;
} else { } else {
$username = $repository->getDetail('ssh-login'); $username = $repository->getDetail('ssh-login');
if (!$username) {
// If there's no explicit username, check for one in the URI. This is
// possible with older repositories.
$username = $uri->getUser();
if (!$username) {
// Also check for a Git/SCP-style URI.
$git_uri = new PhutilGitURI($raw_uri);
$username = $git_uri->getUser();
}
}
$file = $repository->getDetail('ssh-keyfile'); $file = $repository->getDetail('ssh-keyfile');
if ($file) { if ($file) {
$secret = $file; $secret = $file;