1
0
Fork 0

Merge pull request #2682 from gena01/ssh-support-in-github-protocols

Adding ssh protocol support to "github-protocols".
pull/2705/head
Jordi Boggiano 2014-02-13 16:05:58 +01:00
commit 245461d8ed
3 changed files with 11 additions and 6 deletions

View File

@ -294,8 +294,8 @@ EOT
} }
foreach ($vals as $val) { foreach ($vals as $val) {
if (!in_array($val, array('git', 'https'))) { if (!in_array($val, array('git', 'https', 'ssh'))) {
return 'valid protocols include: git, https'; return 'valid protocols include: git, https, ssh';
} }
} }

View File

@ -24,7 +24,7 @@ class Config
'use-include-path' => false, 'use-include-path' => false,
'preferred-install' => 'auto', 'preferred-install' => 'auto',
'notify-on-install' => true, 'notify-on-install' => true,
'github-protocols' => array('git', 'https'), 'github-protocols' => array('git', 'https', 'ssh'),
'vendor-dir' => 'vendor', 'vendor-dir' => 'vendor',
'bin-dir' => '{$vendor-dir}/bin', 'bin-dir' => '{$vendor-dir}/bin',
'cache-dir' => '{$home}/cache', 'cache-dir' => '{$home}/cache',
@ -206,7 +206,7 @@ class Config
case 'github-protocols': case 'github-protocols':
if (reset($this->config['github-protocols']) === 'http') { if (reset($this->config['github-protocols']) === 'http') {
throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https" or "git"'); throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https" or "git" or "ssh"');
} }
return $this->config[$key]; return $this->config[$key];

View File

@ -312,14 +312,19 @@ class GitDownloader extends VcsDownloader
} }
// public github, autoswitch protocols // public github, autoswitch protocols
if (preg_match('{^(?:https?|git)(://'.$this->getGitHubDomainsRegex().'/.*)}', $url, $match)) { if (preg_match('{^(?:https?|git)://'.$this->getGitHubDomainsRegex().'/(.*)}', $url, $match)) {
$protocols = $this->config->get('github-protocols'); $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));
} }
$messages = array(); $messages = array();
foreach ($protocols as $protocol) { foreach ($protocols as $protocol) {
$url = $protocol . $match[1]; if ('ssh' === $protocol) {
$url = "git@" . $match[1] . ":" . $match[2];
} else {
$url = $protocol ."://" . $match[1] . "/" . $match[2];
}
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $ignoredOutput, $cwd)) { if (0 === $this->process->execute(call_user_func($commandCallable, $url), $ignoredOutput, $cwd)) {
return; return;
} }