From 656feda837263cf712c3f78dfb15aedbd274fe90 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 27 Jun 2012 18:28:49 +0200 Subject: [PATCH] Revert previous change, use GIT_ASKPASS env var instead --- src/Composer/Downloader/GitDownloader.php | 4 +++- src/Composer/Repository/Vcs/GitDriver.php | 4 +++- src/Composer/Repository/Vcs/GitHubDriver.php | 1 + tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php | 7 ++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 8978a86ab..0bf8e65ac 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -25,9 +25,11 @@ class GitDownloader extends VcsDownloader public function doDownload(PackageInterface $package, $path) { $ref = $package->getSourceReference(); - $command = 'git clone -c core.askpass=echo %s %s && cd %2$s && git remote add composer %1$s && git fetch composer'; + $command = 'git clone %s %s && cd %2$s && git remote add composer %1$s && git fetch composer'; $this->io->write(" Cloning ".$ref); + // added in git 1.7.1, prevents prompting the user + putenv('GIT_ASKPASS=echo'); $commandCallable = function($url) use ($ref, $path, $command) { return sprintf($command, escapeshellarg($url), escapeshellarg($path), escapeshellarg($ref)); }; diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 1db4fc45e..f31d27bb6 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -48,7 +48,9 @@ class GitDriver extends VcsDriver $fs = new Filesystem(); $fs->removeDirectory($this->repoDir); - $command = sprintf('git clone -c core.askpass=echo --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)); + // added in git 1.7.1, prevents prompting the user + putenv('GIT_ASKPASS=echo'); + $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)); if (0 !== $this->process->execute($command, $output)) { $output = $this->process->getErrorOutput(); diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index c72290190..87d210af4 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -276,6 +276,7 @@ class GitHubDriver extends VcsDriver return; } catch (\RuntimeException $e) { + $this->gitDriver = null; if (!$this->io->isInteractive()) { $this->io->write('Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your username and password'); throw $e; diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 7353e86c5..388b490a3 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -48,6 +48,11 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase ->setConstructorArgs(array($io)) ->getMock(); + $process = $this->getMock('Composer\Util\ProcessExecutor'); + $process->expects($this->any()) + ->method('execute') + ->will($this->returnValue(1)); + $remoteFilesystem->expects($this->at(0)) ->method('getContents') ->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false)) @@ -72,7 +77,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo('github.com'), $this->equalTo($repoApiUrl), $this->equalTo(false)) ->will($this->returnValue('{"master_branch": "test_master"}')); - $gitHubDriver = new GitHubDriver($repoUrl, $io, $this->config, null, $remoteFilesystem); + $gitHubDriver = new GitHubDriver($repoUrl, $io, $this->config, $process, $remoteFilesystem); $gitHubDriver->initialize(); $this->setAttribute($gitHubDriver, 'tags', array($identifier => $sha));