Page MenuHomePhabricator

D13350.diff
No OneTemporary

D13350.diff

diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -230,51 +230,28 @@
->setObject($repository)
->setUser($user);
- if ($repository->isHosted()) {
- $ssh_uri = $repository->getSSHCloneURIObject();
- if ($ssh_uri) {
- $clone_uri = $this->renderCloneCommand(
- $repository,
- $ssh_uri,
- $repository->getServeOverSSH(),
- '/settings/panel/ssh/');
-
- $view->addProperty(
- $repository->isSVN()
- ? pht('Checkout (SSH)')
- : pht('Clone (SSH)'),
- $clone_uri);
- }
+ $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $repository->getPHID(),
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
+ if ($project_phids) {
+ $view->addProperty(
+ pht('Projects'),
+ $user->renderHandleList($project_phids));
+ }
- $http_uri = $repository->getHTTPCloneURIObject();
- if ($http_uri) {
- $clone_uri = $this->renderCloneCommand(
- $repository,
- $http_uri,
- $repository->getServeOverHTTP(),
- PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth')
- ? '/settings/panel/vcspassword/'
- : null);
-
- $view->addProperty(
- $repository->isSVN()
- ? pht('Checkout (HTTP)')
- : pht('Clone (HTTP)'),
- $clone_uri);
- }
- } else {
+ if (!$repository->isHosted()) {
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$view->addProperty(
- pht('Clone'),
+ pht('Clone (Remote)'),
$this->renderCloneCommand(
$repository,
$repository->getPublicCloneURI()));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$view->addProperty(
- pht('Checkout'),
+ pht('Checkout (Remote)'),
$this->renderCloneCommand(
$repository,
$repository->getPublicCloneURI()));
@@ -282,6 +259,38 @@
}
}
+ $ssh_uri = $repository->getInternalSSHCloneURIObject();
+ if ($ssh_uri) {
+ $clone_uri = $this->renderCloneCommand(
+ $repository,
+ $ssh_uri,
+ $repository->getServeOverSSH(),
+ '/settings/panel/ssh/');
+
+ $view->addProperty(
+ $repository->isSVN()
+ ? pht('Checkout (SSH)')
+ : pht('Clone (SSH)'),
+ $clone_uri);
+ }
+
+ $http_uri = $repository->getInternalHTTPCloneURIObject();
+ if ($http_uri) {
+ $clone_uri = $this->renderCloneCommand(
+ $repository,
+ $http_uri,
+ $repository->getServeOverHTTP(),
+ PhabricatorEnv::getEnvConfig('diffusion.allow-http-auth')
+ ? '/settings/panel/vcspassword/'
+ : null);
+
+ $view->addProperty(
+ $repository->isSVN()
+ ? pht('Checkout (HTTP)')
+ : pht('Clone (HTTP)'),
+ $clone_uri);
+ }
+
$view->invokeWillRenderEvent();
$description = $repository->getDetail('description');
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -1004,13 +1004,21 @@
$serve_http = $this->getServeOverHTTP();
if ($serve_ssh === self::SERVE_READWRITE) {
- return $this->getSSHCloneURIObject();
+ return coalesce(
+ $this->getExternalSSHCloneURIObject(),
+ $this->getInternalSSHCloneURIObject());
} else if ($serve_http === self::SERVE_READWRITE) {
- return $this->getHTTPCloneURIObject();
+ return coalesce(
+ $this->getExternalHTTPCloneURIObject(),
+ $this->getInternalHTTPCloneURIObject());
} else if ($serve_ssh !== self::SERVE_OFF) {
- return $this->getSSHCloneURIObject();
+ return coalesce(
+ $this->getExternalSSHCloneURIObject(),
+ $this->getInternalSSHCloneURIObject());
} else if ($serve_http !== self::SERVE_OFF) {
- return $this->getHTTPCloneURIObject();
+ return coalesce(
+ $this->getExternalHTTPCloneURIObject(),
+ $this->getInternalHTTPCloneURIObject());
} else {
return null;
}
@@ -1018,17 +1026,15 @@
/**
- * Get the repository's SSH clone/checkout URI, if one exists.
+ * Get the repository's internal SSH clone/checkout URI.
+ *
+ * All repositories can be served via Phabricator, even if they are hosted
+ * externally. This method returns the SSH clone URI that can be used to
+ * clone/checkout the repository.
+ *
+ * @return string Clone/checkout SSH URI.
*/
- public function getSSHCloneURIObject() {
- if (!$this->isHosted()) {
- if ($this->shouldUseSSH()) {
- return $this->getRemoteURIObject();
- } else {
- return null;
- }
- }
-
+ public function getInternalSSHCloneURIObject() {
$serve_ssh = $this->getServeOverSSH();
if ($serve_ssh === self::SERVE_OFF) {
return null;
@@ -1063,20 +1069,39 @@
return $uri;
}
-
/**
- * Get the repository's HTTP clone/checkout URI, if one exists.
+ * Get the repository's external SSH clone/checkout URI.
+ *
+ * This method returns the SSH clone URI for externally hosted repositories.
+ * For a hosted repository, this method returns `null`.
+ *
+ * @return null|string Clone/checkout SSH URI.
*/
- public function getHTTPCloneURIObject() {
- if (!$this->isHosted()) {
- if ($this->shouldUseHTTP()) {
- return $this->getRemoteURIObject();
- } else {
- return null;
- }
+ public function getExternalSSHCloneURIObject() {
+ if ($this->isHosted()) {
+ return null;
+ }
+
+ if (!$this->shouldUseSSH()) {
+ return null;
}
+ return $this->getRemoteURIObject();
+ }
+
+
+ /**
+ * Get the repository's internal HTTP clone/checkout URI.
+ *
+ * All repositories can be served via Phabricator, even if they are hosted
+ * externally. This method returns the HTTP clone URI that can be used to
+ * clone/checkout the repository.
+ *
+ * @return string Clone/checkout HTTP URI.
+ */
+ public function getInternalHTTPCloneURIObject() {
$serve_http = $this->getServeOverHTTP();
+
if ($serve_http === self::SERVE_OFF) {
return null;
}
@@ -1093,6 +1118,26 @@
return $uri;
}
+ /**
+ * Get the repository's external HTTP clone/checkout URI.
+ *
+ * This method returns the HTTP clone URI for externally hosted repositories.
+ * For a hosted repository, this method returns `null`.
+ *
+ * @return null|string Clone/checkout HTTP URI.
+ */
+ public function getExternalHTTPCloneURIObject() {
+ if ($this->isHosted()) {
+ return null;
+ }
+
+ if (!$this->shouldUseHTTP()) {
+ return null;
+ }
+
+ return $this->getRemoteURIObject();
+ }
+
/**
* Determine if we should connect to the remote using SSH flags and

File Metadata

Mime Type
text/plain
Expires
Sun, May 12, 3:28 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6288059
Default Alt Text
D13350.diff (7 KB)

Event Timeline