Clean up rogue git env vars in case this is running in a git hook, refs #1832
parent
1dd8bffce5
commit
b38db73611
|
@ -27,12 +27,12 @@ class GitDownloader extends VcsDownloader
|
|||
*/
|
||||
public function doDownload(PackageInterface $package, $path)
|
||||
{
|
||||
$this->cleanEnv();
|
||||
|
||||
$ref = $package->getSourceReference();
|
||||
$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));
|
||||
};
|
||||
|
@ -48,6 +48,8 @@ class GitDownloader extends VcsDownloader
|
|||
*/
|
||||
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
|
||||
{
|
||||
$this->cleanEnv();
|
||||
|
||||
$ref = $target->getSourceReference();
|
||||
$this->io->write(" Checking out ".$ref);
|
||||
$command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer';
|
||||
|
@ -58,8 +60,6 @@ class GitDownloader extends VcsDownloader
|
|||
$this->io->setAuthentication($match[3], urldecode($match[1]), urldecode($match[2]));
|
||||
}
|
||||
|
||||
// added in git 1.7.1, prevents prompting the user
|
||||
putenv('GIT_ASKPASS=echo');
|
||||
$commandCallable = function($url) use ($command) {
|
||||
return sprintf($command, escapeshellarg($url));
|
||||
};
|
||||
|
@ -416,4 +416,14 @@ class GitDownloader extends VcsDownloader
|
|||
|
||||
$this->hasStashedChanges = true;
|
||||
}
|
||||
|
||||
protected function cleanEnv()
|
||||
{
|
||||
// clean up rogue git env vars in case this is running in a git hook
|
||||
putenv('GIT_DIR');
|
||||
putenv('GIT_WORK_TREE');
|
||||
|
||||
// added in git 1.7.1, prevents prompting the user for username/password
|
||||
putenv('GIT_ASKPASS=echo');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,13 @@ class GitDriver extends VcsDriver
|
|||
} else {
|
||||
$this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
|
||||
|
||||
// clean up rogue git env vars in case this is running in a git hook
|
||||
putenv('GIT_DIR');
|
||||
putenv('GIT_WORK_TREE');
|
||||
|
||||
// added in git 1.7.1, prevents prompting the user for username/password
|
||||
putenv('GIT_ASKPASS=echo');
|
||||
|
||||
$fs = new Filesystem();
|
||||
$fs->ensureDirectoryExists(dirname($this->repoDir));
|
||||
|
||||
|
@ -58,8 +65,6 @@ class GitDriver extends VcsDriver
|
|||
// clean up directory and do a fresh clone into it
|
||||
$fs->removeDirectory($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();
|
||||
|
|
Loading…
Reference in New Issue