fix git version detection on OSX
[phorkie.git] / src / phorkie / SetupCheck.php
index c459e2af546d251c981fc9f0888dc525e9f53072..c4d365c7a79552166aea7e88413f44ef0087f821 100644 (file)
@@ -24,8 +24,8 @@ class SetupCheck
     {
         $cfg = $GLOBALS['phorkie']['cfg'];
         $this->writableDirs = array(
-            'gitdir' => $cfg['gitdir'],
-            'workdir' => $cfg['workdir'],
+            'gitdir'  => Tools::foldPath($cfg['gitdir']),
+            'workdir' => Tools::foldPath($cfg['workdir']),
         );
         $this->elasticsearch = $cfg['elasticsearch'];
     }
@@ -39,6 +39,7 @@ class SetupCheck
         $sc->checkGit();
         $sc->checkDatabase();
         $sc->checkMimeTypeDetection();
+        $sc->checkRemoteForking();
 
         return $sc->messages;
     }
@@ -47,9 +48,12 @@ class SetupCheck
     {
         foreach ($GLOBALS['phorkie']['cfgfiles'] as $file => $loaded) {
             if ($loaded) {
-                $this->ok('Loaded config file: ' . $file);
+                $this->ok('Loaded config file: ' . Tools::foldPath($file));
             } else {
-                $this->info('Possible config file: ' . $file . ' (not loaded)');
+                $this->info(
+                    'Possible config file: ' . Tools::foldPath($file)
+                    . ' (not loaded)'
+                );
             }
         }
     }
@@ -97,8 +101,9 @@ class SetupCheck
         if ($retval !== 0) {
             $this->fail('Running git executable failed.');
         }
-        if (!preg_match('#^git version ([0-9.]+(rc[0-9]+)?)$#', $line, $matches)) {
+        if (!preg_match('#^git version ([0-9.]+(rc[0-9]+)?)(?: \(Apple Git-\d+\))?$#', $line, $matches)) {
             $this->fail('git version output format unexpected: ' . $line);
+            return;
         }
         if (version_compare($matches[1], '1.7.5') < 0) {
             $this->fail(
@@ -133,6 +138,18 @@ class SetupCheck
         }
     }
 
+    public function checkRemoteForking()
+    {
+        if (!isset($GLOBALS['phorkie']['cfg']['git']['public'])
+            || $GLOBALS['phorkie']['cfg']['git']['public'] == ''
+        ) {
+            $this->fail(
+                'No public git URL prefix configured.'
+                . ' Remote forking will not work'
+            );
+        }
+    }
+
     public function fail($msg)
     {
         $this->messages[] = array('error', $msg);