Fix stripping ".git" from dir names
[phorkie.git] / src / phorkie / Repositories.php
index e0a3985aa461a73fa4be139b5862857fb11744f6..c6059961a3f6ed2b2124276729698ab4ef46fd37 100644 (file)
@@ -16,14 +16,16 @@ class Repositories
     {
         chdir($this->gitDir);
         $dirs = glob('*.git', GLOB_ONLYDIR);
-        array_walk(
-            $dirs,
-            function ($dir) {
-                return substr($dir, 0, -4);
-            }
-        );
+        foreach ($dirs as $key => $dir) {
+            $dirs[$key] = substr($dir, 0, -4);
+        }
         sort($dirs, SORT_NUMERIC);
-        $n = end($dirs) + 1;
+
+        if ($GLOBALS['phorkie']['cfg']['randomIds']) {
+            $n = end($dirs) + mt_rand(65536, 16777216);
+        } else {
+            $n = end($dirs) + 1;
+        }
 
         chdir($this->workDir);
         $dir = $this->workDir . '/' . $n . '/';