Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepository.php
| Show First 20 Lines • Show All 998 Lines • ▼ Show 20 Lines | public function getCloneURIObject() { | ||||
| // Choose the best URI: pick a read/write URI over a URI which is not | // Choose the best URI: pick a read/write URI over a URI which is not | ||||
| // read/write, and SSH over HTTP. | // read/write, and SSH over HTTP. | ||||
| $serve_ssh = $this->getServeOverSSH(); | $serve_ssh = $this->getServeOverSSH(); | ||||
| $serve_http = $this->getServeOverHTTP(); | $serve_http = $this->getServeOverHTTP(); | ||||
| if ($serve_ssh === self::SERVE_READWRITE) { | if ($serve_ssh === self::SERVE_READWRITE) { | ||||
| return $this->getSSHCloneURIObject(); | return coalesce( | ||||
| $this->getExternalSSHCloneURIObject(), | |||||
| $this->getInternalSSHCloneURIObject()); | |||||
| } else if ($serve_http === self::SERVE_READWRITE) { | } else if ($serve_http === self::SERVE_READWRITE) { | ||||
| return $this->getHTTPCloneURIObject(); | return coalesce( | ||||
| $this->getExternalHTTPCloneURIObject(), | |||||
| $this->getInternalHTTPCloneURIObject()); | |||||
| } else if ($serve_ssh !== self::SERVE_OFF) { | } else if ($serve_ssh !== self::SERVE_OFF) { | ||||
| return $this->getSSHCloneURIObject(); | return coalesce( | ||||
| $this->getExternalSSHCloneURIObject(), | |||||
| $this->getInternalSSHCloneURIObject()); | |||||
| } else if ($serve_http !== self::SERVE_OFF) { | } else if ($serve_http !== self::SERVE_OFF) { | ||||
| return $this->getHTTPCloneURIObject(); | return coalesce( | ||||
| $this->getExternalHTTPCloneURIObject(), | |||||
| $this->getInternalHTTPCloneURIObject()); | |||||
| } else { | } else { | ||||
| return null; | return null; | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * 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() { | public function getInternalSSHCloneURIObject() { | ||||
| if (!$this->isHosted()) { | |||||
| if ($this->shouldUseSSH()) { | |||||
| return $this->getRemoteURIObject(); | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| $serve_ssh = $this->getServeOverSSH(); | $serve_ssh = $this->getServeOverSSH(); | ||||
| if ($serve_ssh === self::SERVE_OFF) { | if ($serve_ssh === self::SERVE_OFF) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| $uri = new PhutilURI(PhabricatorEnv::getProductionURI($this->getURI())); | $uri = new PhutilURI(PhabricatorEnv::getProductionURI($this->getURI())); | ||||
| if ($this->isSVN()) { | if ($this->isSVN()) { | ||||
| Show All 18 Lines | if (strlen($ssh_host)) { | ||||
| $uri->setDomain($ssh_host); | $uri->setDomain($ssh_host); | ||||
| } | } | ||||
| $uri->setPort(PhabricatorEnv::getEnvConfig('diffusion.ssh-port')); | $uri->setPort(PhabricatorEnv::getEnvConfig('diffusion.ssh-port')); | ||||
| return $uri; | 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() { | public function getExternalSSHCloneURIObject() { | ||||
| if (!$this->isHosted()) { | if ($this->isHosted()) { | ||||
| if ($this->shouldUseHTTP()) { | return null; | ||||
| return $this->getRemoteURIObject(); | } | ||||
| } else { | |||||
| if (!$this->shouldUseSSH()) { | |||||
| return null; | 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(); | $serve_http = $this->getServeOverHTTP(); | ||||
| if ($serve_http === self::SERVE_OFF) { | if ($serve_http === self::SERVE_OFF) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| $uri = PhabricatorEnv::getProductionURI($this->getURI()); | $uri = PhabricatorEnv::getProductionURI($this->getURI()); | ||||
| $uri = new PhutilURI($uri); | $uri = new PhutilURI($uri); | ||||
| if ($this->isGit()) { | if ($this->isGit()) { | ||||
| $uri->setPath($uri->getPath().$this->getCloneName().'.git'); | $uri->setPath($uri->getPath().$this->getCloneName().'.git'); | ||||
| } else if ($this->isHg()) { | } else if ($this->isHg()) { | ||||
| $uri->setPath($uri->getPath().$this->getCloneName().'/'); | $uri->setPath($uri->getPath().$this->getCloneName().'/'); | ||||
| } | } | ||||
| return $uri; | 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 | * Determine if we should connect to the remote using SSH flags and | ||||
| * credentials. | * credentials. | ||||
| * | * | ||||
| * @return bool True to use the SSH protocol. | * @return bool True to use the SSH protocol. | ||||
| * @task uri | * @task uri | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 841 Lines • Show Last 20 Lines | |||||