Differential D8097 Diff 18346 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 170 Lines • ▼ Show 20 Lines | if ($project_phids) { | ||||
$view->addProperty( | $view->addProperty( | ||||
pht('Projects'), | pht('Projects'), | ||||
$this->renderHandlesForPHIDs($project_phids)); | $this->renderHandlesForPHIDs($project_phids)); | ||||
} | } | ||||
if ($repository->isHosted()) { | if ($repository->isHosted()) { | ||||
$ssh_uri = $repository->getSSHCloneURIObject(); | $ssh_uri = $repository->getSSHCloneURIObject(); | ||||
if ($ssh_uri) { | if ($ssh_uri) { | ||||
$clone_uri = $this->renderCloneURI( | $clone_uri = $this->renderCloneCommand( | ||||
$repository, | |||||
$ssh_uri, | $ssh_uri, | ||||
$repository->getServeOverSSH(), | $repository->getServeOverSSH(), | ||||
'/settings/panel/ssh/'); | '/settings/panel/ssh/'); | ||||
$view->addProperty(pht('Clone URI (SSH)'), $clone_uri); | $view->addProperty( | ||||
$repository->isSVN() | |||||
? pht('Checkout (SSH)') | |||||
: pht('Clone (SSH)'), | |||||
$clone_uri); | |||||
} | } | ||||
$http_uri = $repository->getHTTPCloneURIObject(); | $http_uri = $repository->getHTTPCloneURIObject(); | ||||
if ($http_uri) { | if ($http_uri) { | ||||
$clone_uri = $this->renderCloneURI( | $clone_uri = $this->renderCloneCommand( | ||||
$repository, | |||||
$http_uri, | $http_uri, | ||||
$repository->getServeOverHTTP(), | $repository->getServeOverHTTP(), | ||||
PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth') | PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth') | ||||
? '/settings/panel/vcspassword/' | ? '/settings/panel/vcspassword/' | ||||
: null); | : null); | ||||
$view->addProperty(pht('Clone URI (HTTP)'), $clone_uri); | $view->addProperty( | ||||
$repository->isSVN() | |||||
? pht('Checkout (HTTP)') | |||||
: pht('Clone (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->renderCloneCommand( | ||||
$repository, | |||||
$repository->getPublicCloneURI())); | $repository->getPublicCloneURI())); | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
$view->addProperty( | $view->addProperty( | ||||
pht('Repository Root'), | pht('Checkout'), | ||||
$this->renderCloneURI( | $this->renderCloneCommand( | ||||
$repository, | |||||
$repository->getPublicCloneURI())); | $repository->getPublicCloneURI())); | ||||
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 302 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 renderCloneCommand( | ||||
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->getCloneName()); | |||||
break; | |||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | |||||
$command = csprintf( | |||||
'hg clone %s %s', | |||||
$uri, | |||||
$repository->getCloneName()); | |||||
break; | |||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | |||||
$command = csprintf( | |||||
'svn checkout %s %s', | |||||
$uri, | |||||
$repository->getCloneName()); | |||||
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 |