浏览代码

Detect color.ui always git setting as bad, fixes #2544

Jordi Boggiano 11 年之前
父节点
当前提交
7c1042eef5
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      src/Composer/Command/DiagnoseCommand.php

+ 16 - 0
src/Composer/Command/DiagnoseCommand.php

@@ -18,6 +18,7 @@ use Composer\Downloader\TransportException;
 use Composer\Plugin\CommandEvent;
 use Composer\Plugin\CommandEvent;
 use Composer\Plugin\PluginEvents;
 use Composer\Plugin\PluginEvents;
 use Composer\Util\ConfigValidator;
 use Composer\Util\ConfigValidator;
+use Composer\Util\ProcessExecutor;
 use Composer\Util\RemoteFilesystem;
 use Composer\Util\RemoteFilesystem;
 use Composer\Util\StreamContextFactory;
 use Composer\Util\StreamContextFactory;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputInterface;
@@ -29,6 +30,7 @@ use Symfony\Component\Console\Output\OutputInterface;
 class DiagnoseCommand extends Command
 class DiagnoseCommand extends Command
 {
 {
     protected $rfs;
     protected $rfs;
+    protected $process;
     protected $failures = 0;
     protected $failures = 0;
 
 
     protected function configure()
     protected function configure()
@@ -47,10 +49,14 @@ EOT
     protected function execute(InputInterface $input, OutputInterface $output)
     protected function execute(InputInterface $input, OutputInterface $output)
     {
     {
         $this->rfs = new RemoteFilesystem($this->getIO());
         $this->rfs = new RemoteFilesystem($this->getIO());
+        $this->process = new ProcessExecutor($this->getIO());
 
 
         $output->write('Checking platform settings: ');
         $output->write('Checking platform settings: ');
         $this->outputResult($output, $this->checkPlatform());
         $this->outputResult($output, $this->checkPlatform());
 
 
+        $output->write('Checking git settings: ');
+        $this->outputResult($output, $this->checkGit());
+
         $output->write('Checking http connectivity: ');
         $output->write('Checking http connectivity: ');
         $this->outputResult($output, $this->checkHttp());
         $this->outputResult($output, $this->checkHttp());
 
 
@@ -119,6 +125,16 @@ EOT
         return true;
         return true;
     }
     }
 
 
+    private function checkGit()
+    {
+        $this->process->execute('git config color.ui', $output);
+        if (strtolower(trim($output)) === 'always') {
+            return '<warning>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.</warning>';
+        }
+
+        return true;
+    }
+
     private function checkHttp()
     private function checkHttp()
     {
     {
         $protocol = extension_loaded('openssl') ? 'https' : 'http';
         $protocol = extension_loaded('openssl') ? 'https' : 'http';