public function getRemoteURI() { $raw_uri = $this->getDetail('remote-uri'); if (!$raw_uri) { return null; } if (strpos($raw_uri, '/') === 0) { // If the URI starts with a '/', it's an implicit file:// URI on the // local disk. $uri = new PhutilURI('file://' . $raw_uri); return (string) $uri; } $uri = new PhutilURI($raw_uri); if ($uri->getProtocol()) { if ($this->isSSHProtocol($uri->getProtocol())) { if ($this->getSSHLogin()) { $uri->setUser($this->getSSHLogin()); } } return (string) $uri; } $uri = new PhutilGitURI($raw_uri); if ($uri->getDomain()) { if ($this->getSSHLogin()) { $uri->setUser($this->getSSHLogin()); } return (string) $uri; } throw new Exception("Repository remote URI '{$raw_uri}' could not be parsed!"); }
/** * Get a parsed object representation of the repository's remote URI. This * may be a normal URI (returned as a @{class:PhutilURI}) or a git URI * (returned as a @{class:PhutilGitURI}). * * @return wild A @{class:PhutilURI} or @{class:PhutilGitURI}. * @task uri */ private function getRemoteURIObject() { $raw_uri = $this->getDetail('remote-uri'); if (!$raw_uri) { return new PhutilURI(''); } if (!strncmp($raw_uri, '/', 1)) { return new PhutilURI('file://' . $raw_uri); } $uri = new PhutilURI($raw_uri); if ($uri->getProtocol()) { if ($this->isSSHProtocol($uri->getProtocol())) { if ($this->getSSHLogin()) { $uri->setUser($this->getSSHLogin()); } } return $uri; } $uri = new PhutilGitURI($raw_uri); if ($uri->getDomain()) { if ($this->getSSHLogin()) { $uri->setUser($this->getSSHLogin()); } return $uri; } throw new Exception("Remote URI '{$raw_uri}' could not be parsed!"); }