Browse Source

Code cleanups, enforce url for https, refs #2009

Jordi Boggiano 12 years ago
parent
commit
7b6f0ab047
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/Composer/Downloader/GitDownloader.php

+ 5 - 2
src/Composer/Downloader/GitDownloader.php

@@ -305,7 +305,7 @@ class GitDownloader extends VcsDownloader
             }
             }
 
 
             // failed to checkout, first check git accessibility
             // 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);
         $command = call_user_func($commandCallable, $url);
@@ -381,7 +381,10 @@ class GitDownloader extends VcsDownloader
         // set push url for github projects
         // set push url for github projects
         if (preg_match('{^(?:https?|git)://github.com/([^/]+)/([^/]+?)(?:\.git)?$}', $package->getSourceUrl(), $match)) {
         if (preg_match('{^(?:https?|git)://github.com/([^/]+)/([^/]+?)(?:\.git)?$}', $package->getSourceUrl(), $match)) {
             $protocols = $this->config->get('github-protocols');
             $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));
             $cmd = sprintf('git remote set-url --push origin %s', escapeshellarg($pushUrl));
             $this->process->execute($cmd, $ignoredOutput, $path);
             $this->process->execute($cmd, $ignoredOutput, $path);
         }
         }