*/ 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:----L1GMNgcmwd44dGxKMpJ09+AaNeD9ElUBJChKQzNdNP8bhSQLeE3GE6KWWH3/dOYjMH3njWUP2+I7f+ZyztEmHM7oUvnL1oTlyJMEIDGTIQGkwYfLjiI57oEw9E755wJb8yIcARgUpunCqtU/s+kq+liIK+doEYc0qA1ycss6LL18va8DX0DSNHbFNltXU4WvSJQX/m31bRk3uK8FSEbqe9FD0GAK25wdt2RBkOqjXxQ6Dh0CbWhs99d35Qu48sBl8QPPDh7suoXGiacQnYszALwG8wSOla02f24Chry4Aqda5dWOHuPVbQf/G/BQ52+59pqeEN8OZ5qFc5aN86Vu0x/3WHQn+4Kau567gBQBh9kghLHJjC0Js9ei/Jxgm9b+b3cAzBkH9mr9fWgidobn6iOyPZKq4JvfUDBzvOkestvxWUx9VwtSNBKk67U865JncMa8tCQYf1PfnCEc7sZTSNefGEjgG0xSmZtJKDFUX2p00qx/NlwnhsJb+WnLhoALwtoBmeyr2chkJ1fAv2qp8Ro+uc15cDqYT5TNkJzojU216++4MKksBqMWCuR0lAMEXjIHB8QuGAedyNAPDA/SdeMfu2NLszwj7HBmjHEr49EUOue8b7wWssbRkMst8+/wvoUbMxcmOJUfYWRcmMCNmWeNc3EgbVE4rYl2lnBUITU=----ATTACHMENT:----NTc4MDg4MDQzNjMyMzkwOCAxOTY3MDc5MjkwNzM1MDU4IDI2OTU2NjM2OTk0NTMxMDU=