3 final class DiffusionCloneController
extends DiffusionController
{
5 public function shouldAllowPublic() {
9 public function handleRequest(AphrontRequest
$request) {
10 $viewer = $request->getViewer();
11 $response = $this->loadDiffusionContext();
16 $drequest = $this->getDiffusionRequest();
17 $repository = $drequest->getRepository();
19 $view = id(new PHUIPropertyListView())
22 $display_never = PhabricatorRepositoryURI
::DISPLAY_NEVER
;
25 $uris = $repository->getURIs();
26 foreach ($uris as $uri) {
27 if ($uri->getIsDisabled()) {
31 if ($uri->getEffectiveDisplayType() == $display_never) {
35 if ($repository->isSVN()) {
36 $label = phutil_tag_div('diffusion-clone-label', pht('Checkout'));
38 $label = phutil_tag_div('diffusion-clone-label', pht('Clone'));
43 $this->renderCloneURI($repository, $uri));
46 if (!$view->hasAnyProperties()) {
47 $view = id(new PHUIInfoView())
48 ->setSeverity(PHUIInfoView
::SEVERITY_NOTICE
)
49 ->appendChild(pht('Repository has no URIs set.'));
54 // Try to load alternatives. This may fail for repositories which have not
55 // cloned yet. If it does, just ignore it and continue.
57 $alternatives = $drequest->getRefAlternatives();
58 } catch (ConduitClientException
$ex) {
59 $alternatives = array();
65 'The ref "%s" is ambiguous in this repository.',
66 $drequest->getBranch()),
71 'href' => $drequest->generateURI(
76 pht('View Alternatives')),
79 $messages = array($message);
81 $warning = id(new PHUIInfoView())
82 ->setSeverity(PHUIInfoView
::SEVERITY_WARNING
)
83 ->setErrors(array($message));
86 $cancel_uri = $drequest->generateURI(
92 return $this->newDialog()
93 ->setTitle(pht('Clone Repository'))
94 ->setWidth(AphrontDialogView
::WIDTH_FORM
)
95 ->addCancelButton($cancel_uri, pht('Close'))
96 ->appendChild(array($view, $warning));
99 private function renderCloneURI(
100 PhabricatorRepository
$repository,
101 PhabricatorRepositoryURI
$uri) {
103 if ($repository->isSVN()) {
105 'svn checkout %R %R',
106 (string)$uri->getDisplayURI(),
107 $repository->getCloneName());
109 $display = csprintf('%R', (string)$uri->getDisplayURI());
112 $display = (string)$display;
113 $viewer = $this->getViewer();
115 return id(new DiffusionCloneURIView())
117 ->setRepository($repository)
118 ->setRepositoryURI($uri)
119 ->setDisplayURI($display);