Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
3.1 kB · 120 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121<?php
final class DiffusionCloneController extends DiffusionController {
public function shouldAllowPublic() { return true; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $response = $this->loadDiffusionContext(); if ($response) { return $response; }
$drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository();
$view = id(new PHUIPropertyListView()) ->setUser($viewer);
$display_never = PhabricatorRepositoryURI::DISPLAY_NEVER; $warning = null;
$uris = $repository->getURIs(); foreach ($uris as $uri) { if ($uri->getIsDisabled()) { continue; }
if ($uri->getEffectiveDisplayType() == $display_never) { continue; }
if ($repository->isSVN()) { $label = phutil_tag_div('diffusion-clone-label', pht('Checkout')); } else { $label = phutil_tag_div('diffusion-clone-label', pht('Clone')); }
$view->addProperty( $label, $this->renderCloneURI($repository, $uri)); }
if (!$view->hasAnyProperties()) { $view = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ->appendChild(pht('Repository has no URIs set.')); }
// Try to load alternatives. This may fail for repositories which have not // cloned yet. If it does, just ignore it and continue. try { $alternatives = $drequest->getRefAlternatives(); } catch (ConduitClientException $ex) { $alternatives = array(); }
if ($alternatives) { $message = array( pht( 'The ref "%s" is ambiguous in this repository.', $drequest->getBranch()), ' ', phutil_tag( 'a', array( 'href' => $drequest->generateURI( array( 'action' => 'refs', )), ), pht('View Alternatives')), );
$messages = array($message);
$warning = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_WARNING) ->setErrors(array($message)); }
$cancel_uri = $drequest->generateURI( array( 'action' => 'branch', 'path' => '/', ));
return $this->newDialog() ->setTitle(pht('Clone Repository')) ->setWidth(AphrontDialogView::WIDTH_FORM) ->addCancelButton($cancel_uri, pht('Close')) ->appendChild(array($view, $warning)); }
private function renderCloneURI( PhabricatorRepository $repository, PhabricatorRepositoryURI $uri) {
if ($repository->isSVN()) { $display = csprintf( 'svn checkout %R %R', (string)$uri->getDisplayURI(), $repository->getCloneName()); } else { $display = csprintf('%R', (string)$uri->getDisplayURI()); }
$display = (string)$display; $viewer = $this->getViewer();
return id(new DiffusionCloneURIView()) ->setViewer($viewer) ->setRepository($repository) ->setRepositoryURI($uri) ->setDisplayURI($display); }
}