Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepositoryURI.php
Show First 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | private function getURIObject($normalize) { | ||||
$default_ports = array( | $default_ports = array( | ||||
'ssh' => 22, | 'ssh' => 22, | ||||
'http' => 80, | 'http' => 80, | ||||
'https' => 443, | 'https' => 443, | ||||
); | ); | ||||
$uri = new PhutilURI($raw_uri); | $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); | |||||
if (!$uri->getProtocol()) { | if (!$uri->getProtocol()) { | ||||
$git_uri = new PhutilGitURI($raw_uri); | $git_uri = new PhutilGitURI($raw_uri); | ||||
// We must normalize this Git-style URI into a normal URI | // We must normalize this Git-style URI into a normal URI | ||||
$must_normalize = ($port && ($port != $default_ports['ssh'])); | $must_normalize = ($port && ($port != $default_ports['ssh'])); | ||||
if ($must_normalize || $normalize) { | if ($must_normalize || $normalize) { | ||||
$domain = $git_uri->getDomain(); | $domain = $git_uri->getDomain(); | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | final class PhabricatorRepositoryURI | ||||
public function getAvailableIOTypeOptions() { | public function getAvailableIOTypeOptions() { | ||||
$options = array( | $options = array( | ||||
self::IO_DEFAULT, | self::IO_DEFAULT, | ||||
self::IO_NONE, | self::IO_NONE, | ||||
); | ); | ||||
if ($this->isBuiltin()) { | if ($this->isBuiltin()) { | ||||
$options[] = self::IO_READ; | $options[] = self::IO_READ; | ||||
$options[] = self::IO_WRITE; | $options[] = self::IO_READWRITE; | ||||
} else { | } else { | ||||
$options[] = self::IO_OBSERVE; | $options[] = self::IO_OBSERVE; | ||||
$options[] = self::IO_MIRROR; | $options[] = self::IO_MIRROR; | ||||
} | } | ||||
$map = array(); | $map = array(); | ||||
$io_map = self::getIOTypeMap(); | $io_map = self::getIOTypeMap(); | ||||
foreach ($options as $option) { | foreach ($options as $option) { | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | public function newCommandEngine() { | ||||
$repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
$protocol = $this->getEffectiveURI()->getProtocol(); | $protocol = $this->getEffectiveURI()->getProtocol(); | ||||
return DiffusionCommandEngine::newCommandEngine($repository) | return DiffusionCommandEngine::newCommandEngine($repository) | ||||
->setCredentialPHID($this->getCredentialPHID()) | ->setCredentialPHID($this->getCredentialPHID()) | ||||
->setProtocol($protocol); | ->setProtocol($protocol); | ||||
} | } | ||||
public function getURIScore() { | |||||
$score = 0; | |||||
$io_points = array( | |||||
self::IO_READWRITE => 20, | |||||
self::IO_READ => 10, | |||||
); | |||||
$score += idx($io_points, $this->getEffectiveIoType(), 0); | |||||
$protocol_points = array( | |||||
self::BUILTIN_PROTOCOL_SSH => 3, | |||||
self::BUILTIN_PROTOCOL_HTTPS => 2, | |||||
self::BUILTIN_PROTOCOL_HTTP => 1, | |||||
); | |||||
$score += idx($protocol_points, $this->getBuiltinProtocol(), 0); | |||||
return $score; | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | ||||
public function getApplicationTransactionEditor() { | public function getApplicationTransactionEditor() { | ||||
return new DiffusionURIEditor(); | return new DiffusionURIEditor(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |