@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.

Use HTTPEngineExtension proxy for `git` HTTP operations

Summary: Ref T10227. When we perform `git` http operations (fetch, mirror) check if we should use a proxy; if we should, set `http_proxy` or `https_proxy` in the environment to make `git` have `curl` use it.

Test Plan:
- Configured a proxy extension to run stuff through a local instance of Charles.
- Ran `repository pull` and `repository mirror`.
- Saw `git` HTTP requests route through the proxy.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10227

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

+30 -5
+11
src/applications/diffusion/protocol/DiffusionCommandEngine.php
··· 9 9 private $passthru; 10 10 private $connectAsDevice; 11 11 private $sudoAsDaemon; 12 + private $uri; 12 13 13 14 public static function newCommandEngine(PhabricatorRepository $repository) { 14 15 $engines = self::newCommandEngines(); ··· 46 47 47 48 public function getRepository() { 48 49 return $this->repository; 50 + } 51 + 52 + public function setURI(PhutilURI $uri) { 53 + $this->uri = $uri; 54 + $this->setProtocol($uri->getProtocol()); 55 + return $this; 56 + } 57 + 58 + public function getURI() { 59 + return $this->uri; 49 60 } 50 61 51 62 public function setProtocol($protocol) {
+15
src/applications/diffusion/protocol/DiffusionGitCommandEngine.php
··· 30 30 $env['GIT_SSH'] = $this->getSSHWrapper(); 31 31 } 32 32 33 + if ($this->isAnyHTTPProtocol()) { 34 + $uri = $this->getURI(); 35 + if ($uri) { 36 + $proxy = PhutilHTTPEngineExtension::buildHTTPProxyURI($uri); 37 + if ($proxy) { 38 + if ($this->isHTTPSProtocol()) { 39 + $env_key = 'https_proxy'; 40 + } else { 41 + $env_key = 'http_proxy'; 42 + } 43 + $env[$env_key] = (string)$proxy; 44 + } 45 + } 46 + } 47 + 33 48 return $env; 34 49 } 35 50
+2 -2
src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
··· 598 598 ->setArgv($argv) 599 599 ->setSudoAsDaemon(true) 600 600 ->setCredentialPHID($repository->getCredentialPHID()) 601 - ->setProtocol($repository->getRemoteProtocol()) 601 + ->setURI($repository->getRemoteURI()) 602 602 ->newFuture(); 603 603 604 604 $future->setCWD($local_path); ··· 704 704 ->setArgv($argv) 705 705 ->setConnectAsDevice(true) 706 706 ->setSudoAsDaemon(true) 707 - ->setProtocol($fetch_uri->getProtocol()) 707 + ->setURI($fetch_uri) 708 708 ->newFuture(); 709 709 710 710 $future->setCWD($local_path);
+1 -1
src/applications/repository/storage/PhabricatorRepository.php
··· 508 508 return DiffusionCommandEngine::newCommandEngine($this) 509 509 ->setArgv($argv) 510 510 ->setCredentialPHID($this->getCredentialPHID()) 511 - ->setProtocol($this->getRemoteProtocol()); 511 + ->setURI($this->getRemoteURIObject()); 512 512 } 513 513 514 514 /* -( Local Command Execution )-------------------------------------------- */
+1 -2
src/applications/repository/storage/PhabricatorRepositoryURI.php
··· 587 587 588 588 public function newCommandEngine() { 589 589 $repository = $this->getRepository(); 590 - $protocol = $this->getEffectiveURI()->getProtocol(); 591 590 592 591 return DiffusionCommandEngine::newCommandEngine($repository) 593 592 ->setCredentialPHID($this->getCredentialPHID()) 594 - ->setProtocol($protocol); 593 + ->setURI($this->getEffectiveURI()); 595 594 } 596 595 597 596 public function getURIScore() {