1
0
Fork 0

Add git version to diagnose command, and warn if <2.24, closes #10832

pull/10893/head
Jordi Boggiano 2022-06-22 13:03:36 +02:00
parent 567423e9f7
commit 81043c5691
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 12 additions and 5 deletions

View File

@ -21,6 +21,7 @@ use Composer\Repository\PlatformRepository;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
use Composer\Util\ConfigValidator;
use Composer\Util\Git;
use Composer\Util\IniHelper;
use Composer\Util\ProcessExecutor;
use Composer\Util\HttpDownloader;
@ -225,10 +226,7 @@ EOT
return true;
}
/**
* @return string|true
*/
private function checkGit()
private function checkGit(): string
{
if (!function_exists('proc_open')) {
return '<comment>proc_open is not available, git cannot be used</comment>';
@ -239,7 +237,16 @@ EOT
return '<comment>Your git color.ui setting is set to always, this is known to create issues. Use "git config --global color.ui true" to set it correctly.</comment>';
}
return true;
$gitVersion = Git::getVersion($this->process);
if (version_compare('2.24.0', $gitVersion, '>')) {
return '<warning>Your git version ('.$gitVersion.') is too old and possibly will cause issues. Please upgrade to git 2.24 or above</>';
}
if (null === $gitVersion) {
return '<comment>No git process found</>';
}
return '<info>OK</> <comment>git version '.$gitVersion.'</>';
}
/**