Distinguish between "Remote URI" and "Clone URI" in Repositories
Summary: Hosted repositories have muddied this distinction somewhat. In some cases, we only want to use the real remote URI, and the call is only relevant for imported repositories. In other cases, we want the URI we'd plug into `git clone`. Move this logic into `PhabricatorRepository` and make the distinction more clear. Test Plan: Viewed SVN, Git, and Mercurial hosted and remote repositories, all the URIs looked reasonable. Reviewers: btrahan Reviewed By: btrahan CC: aran, dctrwatson Differential Revision: https://secure.phabricator.com/D8096
This commit is contained in:
@@ -174,42 +174,21 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
}
|
||||
|
||||
if ($repository->isHosted()) {
|
||||
$serve_off = PhabricatorRepository::SERVE_OFF;
|
||||
$callsign = $repository->getCallsign();
|
||||
$repo_path = '/diffusion/'.$callsign.'/';
|
||||
|
||||
$serve_ssh = $repository->getServeOverSSH();
|
||||
if ($serve_ssh !== $serve_off) {
|
||||
$uri = new PhutilURI(PhabricatorEnv::getProductionURI($repo_path));
|
||||
|
||||
if ($repository->isSVN()) {
|
||||
$uri->setProtocol('svn+ssh');
|
||||
} else {
|
||||
$uri->setProtocol('ssh');
|
||||
}
|
||||
|
||||
$ssh_user = PhabricatorEnv::getEnvConfig('diffusion.ssh-user');
|
||||
if ($ssh_user) {
|
||||
$uri->setUser($ssh_user);
|
||||
}
|
||||
|
||||
$uri->setPort(PhabricatorEnv::getEnvConfig('diffusion.ssh-port'));
|
||||
|
||||
$ssh_uri = $repository->getSSHCloneURIObject();
|
||||
if ($ssh_uri) {
|
||||
$clone_uri = $this->renderCloneURI(
|
||||
$uri,
|
||||
$serve_ssh,
|
||||
$ssh_uri,
|
||||
$repository->getServeOverSSH(),
|
||||
'/settings/panel/ssh/');
|
||||
|
||||
$view->addProperty(pht('Clone URI (SSH)'), $clone_uri);
|
||||
}
|
||||
|
||||
$serve_http = $repository->getServeOverHTTP();
|
||||
if ($serve_http !== $serve_off) {
|
||||
$http_uri = PhabricatorEnv::getProductionURI($repo_path);
|
||||
|
||||
$http_uri = $repository->getHTTPCloneURIObject();
|
||||
if ($http_uri) {
|
||||
$clone_uri = $this->renderCloneURI(
|
||||
$http_uri,
|
||||
$serve_http,
|
||||
$repository->getServeOverHTTP(),
|
||||
PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth')
|
||||
? '/settings/panel/vcspassword/'
|
||||
: null);
|
||||
@@ -223,13 +202,13 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||
$view->addProperty(
|
||||
pht('Clone URI'),
|
||||
$this->renderCloneURI(
|
||||
$repository->getPublicRemoteURI()));
|
||||
$repository->getPublicCloneURI()));
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$view->addProperty(
|
||||
pht('Repository Root'),
|
||||
$this->renderCloneURI(
|
||||
$repository->getPublicRemoteURI()));
|
||||
$repository->getPublicCloneURI()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user