From 7c1042eef56f54df957f89487534db8b080c1c84 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 3 Jan 2014 18:22:05 +0100 Subject: [PATCH] Detect color.ui always git setting as bad, fixes #2544 --- src/Composer/Command/DiagnoseCommand.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 879e139d2..445bcc1aa 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -18,6 +18,7 @@ use Composer\Downloader\TransportException; use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; use Composer\Util\ConfigValidator; +use Composer\Util\ProcessExecutor; use Composer\Util\RemoteFilesystem; use Composer\Util\StreamContextFactory; use Symfony\Component\Console\Input\InputInterface; @@ -29,6 +30,7 @@ use Symfony\Component\Console\Output\OutputInterface; class DiagnoseCommand extends Command { protected $rfs; + protected $process; protected $failures = 0; protected function configure() @@ -47,10 +49,14 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { $this->rfs = new RemoteFilesystem($this->getIO()); + $this->process = new ProcessExecutor($this->getIO()); $output->write('Checking platform settings: '); $this->outputResult($output, $this->checkPlatform()); + $output->write('Checking git settings: '); + $this->outputResult($output, $this->checkGit()); + $output->write('Checking http connectivity: '); $this->outputResult($output, $this->checkHttp()); @@ -119,6 +125,16 @@ EOT return true; } + private function checkGit() + { + $this->process->execute('git config color.ui', $output); + if (strtolower(trim($output)) === 'always') { + return '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.'; + } + + return true; + } + private function checkHttp() { $protocol = extension_loaded('openssl') ? 'https' : 'http';