Exemplo n.º 1
0
 public function getRemoteURI()
 {
     $raw_uri = $this->getDetail('remote-uri');
     $vcs = $this->getVersionControlSystem();
     $is_git = $vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
     // If there's no protocol (git implicit SSH) reformat the URI to be a
     // normal URI. These git URIs look like "user@domain.com:path" instead of
     // "ssh://user@domain/path".
     $uri = new PhutilURI($raw_uri);
     if ($is_git && !$uri->getProtocol()) {
         list($domain, $path) = explode(':', $raw_uri, 2);
         $uri = new PhutilURI('ssh://' . $domain . '/' . $path);
     }
     if ($this->isSSHProtocol($uri->getProtocol())) {
         if ($this->getSSHLogin()) {
             $uri->setUser($this->getSSHLogin());
         }
     }
     return (string) $uri;
 }
 /**
  * Get the repository's SSH clone/checkout URI, if one exists.
  */
 public function getSSHCloneURIObject()
 {
     if (!$this->isHosted()) {
         if ($this->shouldUseSSH()) {
             return $this->getRemoteURIObject();
         } else {
             return null;
         }
     }
     $serve_ssh = $this->getServeOverSSH();
     if ($serve_ssh === self::SERVE_OFF) {
         return null;
     }
     $uri = new PhutilURI(PhabricatorEnv::getProductionURI($this->getURI()));
     if ($this->isSVN()) {
         $uri->setProtocol('svn+ssh');
     } else {
         $uri->setProtocol('ssh');
     }
     if ($this->isGit()) {
         $uri->setPath($uri->getPath() . $this->getCloneName() . '.git');
     } else {
         if ($this->isHg()) {
             $uri->setPath($uri->getPath() . $this->getCloneName() . '/');
         }
     }
     $ssh_user = PhabricatorEnv::getEnvConfig('diffusion.ssh-user');
     if ($ssh_user) {
         $uri->setUser($ssh_user);
     }
     $ssh_host = PhabricatorEnv::getEnvConfig('diffusion.ssh-host');
     if (strlen($ssh_host)) {
         $uri->setDomain($ssh_host);
     }
     $uri->setPort(PhabricatorEnv::getEnvConfig('diffusion.ssh-port'));
     return $uri;
 }
Exemplo n.º 3
0
 /**
  * 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!");
 }
 private function getURIObject()
 {
     // Users can provide Git/SCP-style URIs in the form "user@host:path".
     // In the general case, these are not equivalent to any "ssh://..." form
     // because the path is relative.
     if ($this->isBuiltin()) {
         $builtin_protocol = $this->getForcedProtocol();
         $builtin_domain = $this->getForcedHost();
         $raw_uri = "{$builtin_protocol}://{$builtin_domain}";
     } else {
         $raw_uri = $this->getURI();
     }
     $port = $this->getForcedPort();
     $default_ports = array('ssh' => 22, 'http' => 80, 'https' => 443);
     $uri = new PhutilURI($raw_uri);
     // Make sure to remove any password from the URI before we do anything
     // with it; this should always be provided by the associated credential.
     $uri->setPass(null);
     $protocol = $this->getForcedProtocol();
     if ($protocol) {
         $uri->setProtocol($protocol);
     }
     if ($port) {
         $uri->setPort($port);
     }
     // Remove any explicitly set default ports.
     $uri_port = $uri->getPort();
     $uri_protocol = $uri->getProtocol();
     $uri_default = idx($default_ports, $uri_protocol);
     if ($uri_default && $uri_default == $uri_port) {
         $uri->setPort(null);
     }
     $user = $this->getForcedUser();
     if ($user) {
         $uri->setUser($user);
     }
     $host = $this->getForcedHost();
     if ($host) {
         $uri->setDomain($host);
     }
     $path = $this->getForcedPath();
     if ($path) {
         $uri->setPath($path);
     }
     return $uri;
 }
 public function getRemoteURI()
 {
     $raw_uri = $this->getDetail('remote-uri');
     $vcs = $this->getVersionControlSystem();
     $is_git = $vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
     if ($is_git) {
         $uri = self::newPhutilURIFromGitURI($raw_uri);
     } else {
         $uri = new PhutilURI($raw_uri);
     }
     if ($this->isSSHProtocol($uri->getProtocol())) {
         if ($this->getSSHLogin()) {
             $uri->setUser($this->getSSHLogin());
         }
     }
     return (string) $uri;
 }
 public function getPublicRemoteURI()
 {
     $uri = new PhutilURI($this->getRemoteURI());
     // Make sure we don't leak anything if this repo is using HTTP Basic Auth
     // with the credentials in the URI or something zany like that.
     $uri->setUser(null);
     $uri->setPass(null);
     return $uri;
 }