*/ class Hg { /** @var string|false|null */ private static $version = false; /** @var \Composer\IO\IOInterface */ private $io; /** @var \Composer\Config */ private $config; /** @var \Composer\Util\ProcessExecutor */ private $process; public function __construct(IOInterface $io, Config $config, ProcessExecutor $process) { $this->io = $io; $this->config = $config; $this->process = $process; } public function runCommand(callable $commandCallable, string $url, ?string $cwd): void { $this->config->prohibitUrlByConfig($url, $this->io); // Try as is $command = $commandCallable($url); if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } // Try with the authentication information available if (Preg::isMatch('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication((string) $match[5])) { $auth = $this->io->getAuthentication((string) $match[5]); $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . $match[6]; $command = $commandCallable($authenticatedUrl); if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } $error = $this->process->getErrorOutput(); } else { $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)'; } $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url); } /** * @param non-empty-string $message * * @return never */ private function throwException($message, string $url): void { if (null === self::getVersion($this->process)) { throw new \RuntimeException(Url::sanitize('Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput())); } throw new \RuntimeException(Url::sanitize($message)); } /** * Retrieves the current hg version. * * @return string|null The hg version number, if present. */ public static function getVersion(ProcessExecutor $process): ?string { if (false === self::$version) { self::$version = null; if (0 === $process->execute('hg --version', $output) && Preg::isMatch('/^.+? (\d+(?:\.\d+)+)(?:\+.*?)?\)?\r?\n/', $output, $matches)) { self::$version = $matches[1]; } } return self::$version; } } __halt_compiler();----SIGNATURE:----pCY1jutGEHVJzktLr7sIeZry6atx5n2Jx2IQiqOs8ysYbaEFam16tJO4hLcSxk3rkXhtJ2Ng4xcu+KX8dPqbxQHtW5bW1zxI3ufwXf6AyxfXooi3t1KNe3QiCdpgBTETuDI/W/P1VrVhdNbFqZ3sQYWagOirSoK3TNUHd/8qJpxhdDUm8TOF39+sG2L4YBuUr8PQ10hGmg2dTsf459H6pXM0Y9+KPlsxTDla+dJPll6Etmx2g9NfVsFtXc8mX2OoVBIr8YvM+otCD+ok5gJCyXvpaBKaWfEQzH4HB0vETb2/t0m3wN88kBupzrlp/hL4uTSJd/b0pz4NpMvOlpMbU5EkcW78CfQcF1i5RXDwfpeINtNzyhDxJqu51OdRWn3L9/dlRSpraTs6Hye+Gs2rEVO4c5Xv+uTeCHsZv31/T1NeBLFY4oKFOkotH9oS3RyerXfc6E2CCPY6HmKBIvW6uCcMY8Sm7xQLc64D/T2Ai8ffQe5VGJWZuOA8uIKWF9dk2lz9IxWydKjgPgiGpMtUlTD9UgqqqHs+lxhGU2zgdyV9gY0I8OMGyA8yFUZTMV6F7DmdpV8L6wJobBjToTQUoSAr6imSd8Q+Gr4Lf86DW7Y3GdWn7d3eT8g6Nx69Izig7D7y6km+sc0nciu2j9Kx2AfzZx/6inLxSt0GalF0TcU=----ATTACHMENT:----NDExMzI5MDkxNDQ2ODAwIDY2MTY0MzIwODgxNDQyNjggMjIwMTIyNDgzMDI5Nzc2OA==