Make Git::cleanEnv static
parent
e23665be59
commit
e0886b94a2
|
@ -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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue