Differential D8090 Diff 18299 src/applications/diffusion/controller/DiffusionRepositoryController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryController.php
| Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | if ($repository->isHosted()) { | ||||
| $callsign = $repository->getCallsign(); | $callsign = $repository->getCallsign(); | ||||
| $repo_path = '/diffusion/'.$callsign.'/'; | $repo_path = '/diffusion/'.$callsign.'/'; | ||||
| $serve_ssh = $repository->getServeOverSSH(); | $serve_ssh = $repository->getServeOverSSH(); | ||||
| if ($serve_ssh !== $serve_off) { | if ($serve_ssh !== $serve_off) { | ||||
| $uri = new PhutilURI(PhabricatorEnv::getProductionURI($repo_path)); | $uri = new PhutilURI(PhabricatorEnv::getProductionURI($repo_path)); | ||||
| if ($repository->isSVN()) { | if ($repository->isSVN()) { | ||||
| $label = pht('Checkout (SSH)'); | |||||
| $uri->setProtocol('svn+ssh'); | $uri->setProtocol('svn+ssh'); | ||||
| } else { | } else { | ||||
| $label = pht('Clone (SSH)'); | |||||
| $uri->setProtocol('ssh'); | $uri->setProtocol('ssh'); | ||||
| } | } | ||||
| $ssh_user = PhabricatorEnv::getEnvConfig('diffusion.ssh-user'); | $ssh_user = PhabricatorEnv::getEnvConfig('diffusion.ssh-user'); | ||||
| if ($ssh_user) { | if ($ssh_user) { | ||||
| $uri->setUser($ssh_user); | $uri->setUser($ssh_user); | ||||
| } | } | ||||
| $uri->setPort(PhabricatorEnv::getEnvConfig('diffusion.ssh-port')); | $uri->setPort(PhabricatorEnv::getEnvConfig('diffusion.ssh-port')); | ||||
| $clone_uri = $this->renderCloneURI( | $clone_uri = $this->renderCloneURI( | ||||
| $repository, | |||||
| $uri, | $uri, | ||||
| $serve_ssh, | $serve_ssh, | ||||
| '/settings/panel/ssh/'); | '/settings/panel/ssh/'); | ||||
| $view->addProperty(pht('Clone URI (SSH)'), $clone_uri); | $view->addProperty(pht('Checkout (SSH)'), $clone_uri); | ||||
| } | } | ||||
| $serve_http = $repository->getServeOverHTTP(); | $serve_http = $repository->getServeOverHTTP(); | ||||
| if ($serve_http !== $serve_off) { | if ($serve_http !== $serve_off) { | ||||
| $http_uri = PhabricatorEnv::getProductionURI($repo_path); | $http_uri = PhabricatorEnv::getProductionURI($repo_path); | ||||
| $clone_uri = $this->renderCloneURI( | $clone_uri = $this->renderCloneURI( | ||||
| $repository, | |||||
| $http_uri, | $http_uri, | ||||
| $serve_http, | $serve_http, | ||||
| PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth') | PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth') | ||||
| ? '/settings/panel/vcspassword/' | ? '/settings/panel/vcspassword/' | ||||
| : null); | : null); | ||||
| if ($repository->isSVN()) { | |||||
| $label = pht('Checkout (HTTP)'); | |||||
| } else { | |||||
| $label = pht('Clone (HTTP)'); | |||||
| } | |||||
| $view->addProperty(pht('Clone URI (HTTP)'), $clone_uri); | $view->addProperty(pht('Clone URI (HTTP)'), $clone_uri); | ||||
| } | } | ||||
| } else { | } else { | ||||
| switch ($repository->getVersionControlSystem()) { | switch ($repository->getVersionControlSystem()) { | ||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | ||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | ||||
| $view->addProperty( | $view->addProperty( | ||||
| pht('Clone URI'), | pht('Clone'), | ||||
| $this->renderCloneURI( | $this->renderCloneURI( | ||||
| $repository, | |||||
| $repository->getPublicRemoteURI())); | $repository->getPublicRemoteURI())); | ||||
| break; | break; | ||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
| $view->addProperty( | $view->addProperty( | ||||
| pht('Repository Root'), | pht('Checkout'), | ||||
| $this->renderCloneURI( | $this->renderCloneURI( | ||||
| $repository, | |||||
| $repository->getPublicRemoteURI())); | $repository->getPublicRemoteURI())); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| $description = $repository->getDetail('description'); | $description = $repository->getDetail('description'); | ||||
| if (strlen($description)) { | if (strlen($description)) { | ||||
| $description = PhabricatorMarkupEngine::renderOneObject( | $description = PhabricatorMarkupEngine::renderOneObject( | ||||
| ▲ Show 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | private function buildBrowseTable( | ||||
| $header->addActionLink($button); | $header->addActionLink($button); | ||||
| $browse_panel->setHeader($header); | $browse_panel->setHeader($header); | ||||
| $browse_panel->appendChild($browse_table); | $browse_panel->appendChild($browse_table); | ||||
| return $browse_panel; | return $browse_panel; | ||||
| } | } | ||||
| private function renderCloneURI( | private function renderCloneURI( | ||||
| PhabricatorRepository $repository, | |||||
| $uri, | $uri, | ||||
| $serve_mode = null, | $serve_mode = null, | ||||
| $manage_uri = null) { | $manage_uri = null) { | ||||
| require_celerity_resource('diffusion-icons-css'); | require_celerity_resource('diffusion-icons-css'); | ||||
| Javelin::initBehavior('select-on-click'); | Javelin::initBehavior('select-on-click'); | ||||
| switch ($repository->getVersionControlSystem()) { | |||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | |||||
| $command = csprintf('git clone %s %s', $uri, $repository->getName()); | |||||
| break; | |||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | |||||
| $command = csprintf('hg clone %s %s', $uri, $repository->getName()); | |||||
| break; | |||||
| case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | |||||
| $command = csprintf('svn checkout %s %s', $uri, $repository->getName()); | |||||
| break; | |||||
| } | |||||
| $input = javelin_tag( | $input = javelin_tag( | ||||
| 'input', | 'input', | ||||
| array( | array( | ||||
| 'type' => 'text', | 'type' => 'text', | ||||
| 'value' => (string)$uri, | 'value' => (string)$command, | ||||
| 'class' => 'diffusion-clone-uri', | 'class' => 'diffusion-clone-uri', | ||||
| 'sigil' => 'select-on-click', | 'sigil' => 'select-on-click', | ||||
| 'readonly' => 'true', | 'readonly' => 'true', | ||||
| )); | )); | ||||
| $extras = array(); | $extras = array(); | ||||
| if ($serve_mode) { | if ($serve_mode) { | ||||
| if ($serve_mode === PhabricatorRepository::SERVE_READONLY) { | if ($serve_mode === PhabricatorRepository::SERVE_READONLY) { | ||||
| Show All 29 Lines | |||||