Skip to content

Commit

Permalink
Revert previous change, use GIT_ASKPASS env var instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jun 27, 2012
1 parent 4ee1ff4 commit 656feda
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Composer/Downloader/GitDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
Expand Down
4 changes: 3 additions & 1 deletion src/Composer/Repository/Vcs/GitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public function initialize()
$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();

Expand Down
1 change: 1 addition & 0 deletions src/Composer/Repository/Vcs/GitHubDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ protected function fetchRootIdentifier()

return;
} catch (\RuntimeException $e) {
$this->gitDriver = null;
if (!$this->io->isInteractive()) {
$this->io->write('<error>Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your username and password</error>');
throw $e;
Expand Down
7 changes: 6 additions & 1 deletion tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function testPrivateRepository()
->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))
Expand All @@ -72,7 +77,7 @@ public function testPrivateRepository()
->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));

Expand Down

0 comments on commit 656feda

Please sign in to comment.