diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 2dc7532a9..2c4884320 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -28,7 +28,7 @@ class GitDownloader extends VcsDownloader */ public function doDownload(PackageInterface $package, $path, $url) { - $this->cleanEnv(); + GitUtil::cleanEnv(); $path = $this->normalizePath($path); $ref = $package->getSourceReference(); @@ -56,7 +56,7 @@ class GitDownloader extends VcsDownloader */ public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url) { - $this->cleanEnv(); + GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { throw new \RuntimeException('The .git directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information'); @@ -90,7 +90,7 @@ class GitDownloader extends VcsDownloader */ public function getLocalChanges(PackageInterface $package, $path) { - $this->cleanEnv(); + GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { return; @@ -109,7 +109,7 @@ class GitDownloader extends VcsDownloader */ protected function cleanChanges(PackageInterface $package, $path, $update) { - $this->cleanEnv(); + GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!$changes = $this->getLocalChanges($package, $path)) { return; @@ -467,12 +467,6 @@ class GitDownloader extends VcsDownloader $this->hasStashedChanges = true; } - protected function cleanEnv() - { - $util = new GitUtil; - $util->cleanEnv(); - } - protected function normalizePath($path) { if (defined('PHP_WINDOWS_VERSION_MAJOR') && strlen($path) > 0) { diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index f177f8eab..300adea17 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -191,8 +191,7 @@ class RootPackageLoader extends ArrayLoader private function guessGitVersion(array $config) { - $util = new GitUtil; - $util->cleanEnv(); + GitUtil::cleanEnv(); // try to fetch current version from git tags if (0 === $this->process->execute('git describe --exact-match --tags', $output)) { diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index ea5297cc3..aa2755915 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -327,8 +327,7 @@ class Locker $sourceRef = $package->getSourceReference() ?: $package->getDistReference(); switch ($sourceType) { case 'git': - $util = new GitUtil; - $util->cleanEnv(); + GitUtil::cleanEnv(); if (0 === $this->process->execute('git log -n1 --pretty=%ct '.escapeshellarg($sourceRef), $output, $path) && preg_match('{^\s*\d+\s*$}', $output)) { $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC')); diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index a37633655..f8fbc715f 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -42,8 +42,7 @@ class GitDriver extends VcsDriver } else { $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/'; - $util = new GitUtil; - $util->cleanEnv(); + GitUtil::cleanEnv(); $fs = new Filesystem(); $fs->ensureDirectoryExists(dirname($this->repoDir)); diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 4b6fcd6f2..f15922a3e 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -17,7 +17,7 @@ namespace Composer\Util; */ class Git { - public function cleanEnv() + public static function cleanEnv() { if (ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) { throw new \RuntimeException('safe_mode is enabled and safe_mode_allowed_env_vars does not contain GIT_ASKPASS, can not set env var. You can disable safe_mode with "-dsafe_mode=0" when running composer');