1
0
Fork 0

Revert previous change, use GIT_ASKPASS env var instead

pull/851/head
Jordi Boggiano 2012-06-27 18:28:49 +02:00
parent 4ee1ff46a8
commit 656feda837
4 changed files with 13 additions and 3 deletions

View File

@ -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));
};

View File

@ -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();

View File

@ -276,6 +276,7 @@ class GitHubDriver extends VcsDriver
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;

View File

@ -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));