Fallback to https directly if ssh proto is disabled on github private repos, fixes #2786
parent
e0ce559838
commit
0c775e997e
|
@ -52,9 +52,10 @@ class Git
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$protocols = $this->config->get('github-protocols');
|
||||||
|
|
||||||
// public github, autoswitch protocols
|
// public github, autoswitch protocols
|
||||||
if (preg_match('{^(?:https?|git)://'.self::getGitHubDomainsRegex($this->config).'/(.*)}', $url, $match)) {
|
if (preg_match('{^(?:https?|git)://'.self::getGitHubDomainsRegex($this->config).'/(.*)}', $url, $match)) {
|
||||||
$protocols = $this->config->get('github-protocols');
|
|
||||||
if (!is_array($protocols)) {
|
if (!is_array($protocols)) {
|
||||||
throw new \RuntimeException('Config value "github-protocols" must be an array, got '.gettype($protocols));
|
throw new \RuntimeException('Config value "github-protocols" must be an array, got '.gettype($protocols));
|
||||||
}
|
}
|
||||||
|
@ -79,8 +80,11 @@ class Git
|
||||||
$this->throwException('Failed to clone ' . self::sanitizeUrl($url) .' via '.implode(', ', $protocols).' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
|
$this->throwException('Failed to clone ' . self::sanitizeUrl($url) .' via '.implode(', ', $protocols).' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we have a private github url and the ssh protocol is disabled then we skip it and directly fallback to https
|
||||||
|
$bypassSshForGitHub = preg_match('{^git@'.self::getGitHubDomainsRegex($this->config).':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
|
||||||
|
|
||||||
$command = call_user_func($commandCallable, $url);
|
$command = call_user_func($commandCallable, $url);
|
||||||
if (0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
|
if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
|
||||||
// private github repository without git access, try https with auth
|
// private github repository without git access, try https with auth
|
||||||
if (preg_match('{^git@'.self::getGitHubDomainsRegex($this->config).':(.+?)\.git$}i', $url, $match)) {
|
if (preg_match('{^git@'.self::getGitHubDomainsRegex($this->config).':(.+?)\.git$}i', $url, $match)) {
|
||||||
if (!$this->io->hasAuthentication($match[1])) {
|
if (!$this->io->hasAuthentication($match[1])) {
|
||||||
|
|
Loading…
Reference in New Issue