From 7b6f0ab04708b507d7f61756b659a336e6341065 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 18 Jun 2013 14:13:46 +0200 Subject: [PATCH] Code cleanups, enforce url for https, refs #2009 --- src/Composer/Downloader/GitDownloader.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index e90357d04..de85446b2 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -305,7 +305,7 @@ class GitDownloader extends VcsDownloader } // failed to checkout, first check git accessibility - $this->throwException('Failed to clone ' . $this->sanitizeUrl($url) .' via git, https and http protocols, aborting.' . "\n\n" . implode("\n", $messages), $url); + $this->throwException('Failed to clone ' . $this->sanitizeUrl($url) .' via '.implode(', ', $protocols).' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url); } $command = call_user_func($commandCallable, $url); @@ -381,7 +381,10 @@ class GitDownloader extends VcsDownloader // set push url for github projects if (preg_match('{^(?:https?|git)://github.com/([^/]+)/([^/]+?)(?:\.git)?$}', $package->getSourceUrl(), $match)) { $protocols = $this->config->get('github-protocols'); - $pushUrl = $protocols[0] === 'git' ? 'git@github.com:'.$match[1].'/'.$match[2].'.git' : $package->getSourceUrl(); + $pushUrl = 'git@github.com:'.$match[1].'/'.$match[2].'.git'; + if ($protocols[0] !== 'git') { + $pushUrl = 'https://github.com/'.$match[1].'/'.$match[2].'.git'; + } $cmd = sprintf('git remote set-url --push origin %s', escapeshellarg($pushUrl)); $this->process->execute($cmd, $ignoredOutput, $path); }