@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove all uses of PhutilGitURI in Phabricator

Summary:
Ref T11137. This class is removed in D16099. Depends on D16099.

`PhutilURI` now attempts to "just work" with Git-style URIs, so at least in theory we can just delete all of this code and pretend it does not exist.

(I've left "Display URI" and "Effective URI" as distinct, at least for now, because I think the distinction may be relevant in the future even though it isn't right now, and to keep this diff small, although I may go remove one after I think about this for a bit.)

Test Plan:
- Created a new Git repository with a Git URI.
- Pulled/updated it, which now works correctly and should resolve the original issue in T11137.
- Verified that daemons now align the origin to a Git-style URI with a relative path, which should resolve the original issue in T11004.
- Grepped for `PhutilGitURI`.
- Also grepped in `arcanist/`, but found no matches, so no patch for that.
- Checked display/conduit URIs.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11137

Differential Revision: https://secure.phabricator.com/D16100

+29 -104
-5
src/applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php
··· 69 69 $uri_object = new PhutilURI($uri); 70 70 $domain = $uri_object->getDomain(); 71 71 72 - if (!strlen($domain)) { 73 - $uri_object = new PhutilGitURI($uri); 74 - $domain = $uri_object->getDomain(); 75 - } 76 - 77 72 $domain = phutil_utf8_strtolower($domain); 78 73 switch ($domain) { 79 74 case 'github.com':
+2 -18
src/applications/repository/data/PhabricatorRepositoryURINormalizer.php
··· 78 78 switch ($this->type) { 79 79 case self::TYPE_GIT: 80 80 $uri = new PhutilURI($this->uri); 81 - if ($uri->getProtocol()) { 82 - return $uri->getPath(); 83 - } 84 - 85 - $uri = new PhutilGitURI($this->uri); 86 - if ($uri->getDomain()) { 87 - return $uri->getPath(); 88 - } 89 - 90 - return $this->uri; 81 + return $uri->getPath(); 91 82 case self::TYPE_SVN: 92 83 case self::TYPE_MERCURIAL: 93 84 $uri = new PhutilURI($this->uri); ··· 136 127 $domain = null; 137 128 138 129 $uri = new PhutilURI($this->uri); 139 - if ($uri->getProtocol()) { 140 - $domain = $uri->getDomain(); 141 - } 142 - 143 - if (!strlen($domain)) { 144 - $uri = new PhutilGitURI($this->uri); 145 - $domain = $uri->getDomain(); 146 - } 130 + $domain = $uri->getDomain(); 147 131 148 132 if (!strlen($domain)) { 149 133 $domain = '<void>';
+7 -38
src/applications/repository/storage/PhabricatorRepository.php
··· 1201 1201 */ 1202 1202 public function getRemoteProtocol() { 1203 1203 $uri = $this->getRemoteURIObject(); 1204 - 1205 - if ($uri instanceof PhutilGitURI) { 1206 - return 'ssh'; 1207 - } else { 1208 - return $uri->getProtocol(); 1209 - } 1204 + return $uri->getProtocol(); 1210 1205 } 1211 1206 1212 1207 1213 1208 /** 1214 - * Get a parsed object representation of the repository's remote URI. This 1215 - * may be a normal URI (returned as a @{class@libphutil:PhutilURI}) or a git 1216 - * URI (returned as a @{class@libphutil:PhutilGitURI}). 1209 + * Get a parsed object representation of the repository's remote URI.. 1217 1210 * 1218 - * @return wild A @{class@libphutil:PhutilURI} or 1219 - * @{class@libphutil:PhutilGitURI}. 1211 + * @return wild A @{class@libphutil:PhutilURI}. 1220 1212 * @task uri 1221 1213 */ 1222 1214 public function getRemoteURIObject() { 1223 1215 $raw_uri = $this->getDetail('remote-uri'); 1224 - if (!$raw_uri) { 1216 + if (!strlen($raw_uri)) { 1225 1217 return new PhutilURI(''); 1226 1218 } 1227 1219 ··· 1229 1221 return new PhutilURI('file://'.$raw_uri); 1230 1222 } 1231 1223 1232 - $uri = new PhutilURI($raw_uri); 1233 - if ($uri->getProtocol()) { 1234 - return $uri; 1235 - } 1236 - 1237 - $uri = new PhutilGitURI($raw_uri); 1238 - if ($uri->getDomain()) { 1239 - return $uri; 1240 - } 1241 - 1242 - throw new Exception(pht("Remote URI '%s' could not be parsed!", $raw_uri)); 1224 + return new PhutilURI($raw_uri); 1243 1225 } 1244 1226 1245 1227 ··· 1666 1648 return $this; 1667 1649 } 1668 1650 1669 - public static function getRemoteURIProtocol($raw_uri) { 1670 - $uri = new PhutilURI($raw_uri); 1671 - if ($uri->getProtocol()) { 1672 - return strtolower($uri->getProtocol()); 1673 - } 1674 - 1675 - $git_uri = new PhutilGitURI($raw_uri); 1676 - if (strlen($git_uri->getDomain()) && strlen($git_uri->getPath())) { 1677 - return 'ssh'; 1678 - } 1679 - 1680 - return null; 1681 - } 1682 - 1683 1651 public static function assertValidRemoteURI($uri) { 1684 1652 if (trim($uri) != $uri) { 1685 1653 throw new Exception( 1686 1654 pht('The remote URI has leading or trailing whitespace.')); 1687 1655 } 1688 1656 1689 - $protocol = self::getRemoteURIProtocol($uri); 1657 + $uri_object = new PhutilURI($uri); 1658 + $protocol = $uri_object->getProtocol(); 1690 1659 1691 1660 // Catch confusion between Git/SCP-style URIs and normal URIs. See T3619 1692 1661 // for discussion. This is usually a user adding "ssh://" to an implicit
+20 -43
src/applications/repository/storage/PhabricatorRepositoryURI.php
··· 191 191 return self::IO_NONE; 192 192 } 193 193 194 - 195 - public function getDisplayURI() { 196 - return $this->getURIObject(false); 197 - } 198 - 199 194 public function getNormalizedURI() { 200 195 $vcs = $this->getRepository()->getVersionControlSystem(); 201 196 ··· 216 211 return $normal_uri->getNormalizedURI(); 217 212 } 218 213 214 + public function getDisplayURI() { 215 + return $this->getURIObject(); 216 + } 217 + 219 218 public function getEffectiveURI() { 220 - return $this->getURIObject(true); 219 + return $this->getURIObject(); 221 220 } 222 221 223 222 public function getURIEnvelope() { ··· 243 242 return new PhutilOpaqueEnvelope((string)$uri); 244 243 } 245 244 246 - private function getURIObject($normalize) { 245 + private function getURIObject() { 247 246 // Users can provide Git/SCP-style URIs in the form "user@host:path". 248 - // These are equivalent to "ssh://user@host/path". We use the more standard 249 - // form internally, and convert to it if we need to specify a port number, 250 - // but try to preserve what the user typed when displaying the URI. 247 + // In the general case, these are not equivalent to any "ssh://..." form 248 + // because the path is relative. 251 249 252 250 if ($this->isBuiltin()) { 253 251 $builtin_protocol = $this->getForcedProtocol(); ··· 271 269 // with it; this should always be provided by the associated credential. 272 270 $uri->setPass(null); 273 271 274 - if (!$uri->getProtocol()) { 275 - $git_uri = new PhutilGitURI($raw_uri); 276 - 277 - // We must normalize this Git-style URI into a normal URI 278 - $must_normalize = ($port && ($port != $default_ports['ssh'])); 279 - if ($must_normalize || $normalize) { 280 - $domain = $git_uri->getDomain(); 272 + $protocol = $this->getForcedProtocol(); 273 + if ($protocol) { 274 + $uri->setProtocol($protocol); 275 + } 281 276 282 - 283 - $uri = id(new PhutilURI("ssh://{$domain}")) 284 - ->setUser($git_uri->getUser()) 285 - ->setPath($git_uri->getPath()); 286 - } else { 287 - $uri = $git_uri; 288 - } 277 + if ($port) { 278 + $uri->setPort($port); 289 279 } 290 280 291 - $is_normal = ($uri instanceof PhutilURI); 281 + // Remove any explicitly set default ports. 282 + $uri_port = $uri->getPort(); 283 + $uri_protocol = $uri->getProtocol(); 292 284 293 - if ($is_normal) { 294 - $protocol = $this->getForcedProtocol(); 295 - if ($protocol) { 296 - $uri->setProtocol($protocol); 297 - } 298 - 299 - if ($port) { 300 - $uri->setPort($port); 301 - } 302 - 303 - // Remove any explicitly set default ports. 304 - $uri_port = $uri->getPort(); 305 - $uri_protocol = $uri->getProtocol(); 306 - 307 - $uri_default = idx($default_ports, $uri_protocol); 308 - if ($uri_default && ($uri_default == $uri_port)) { 309 - $uri->setPort(null); 310 - } 285 + $uri_default = idx($default_ports, $uri_protocol); 286 + if ($uri_default && ($uri_default == $uri_port)) { 287 + $uri->setPort(null); 311 288 } 312 289 313 290 $user = $this->getForcedUser();