X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/a1b772ed96d84480ece5c35eb4c95b692fb63ecc..894b39fb81760fb6fbff105159da993b512f8ce3:/src/phorkie/Repositories.php diff --git a/src/phorkie/Repositories.php b/src/phorkie/Repositories.php index 729ff23..c605996 100644 --- a/src/phorkie/Repositories.php +++ b/src/phorkie/Repositories.php @@ -16,23 +16,25 @@ 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 . '/'; - mkdir($dir, 0777);//FIXME + mkdir($dir, fileperms($this->workDir) & 0777); $r = new Repository(); $r->id = $n; $r->workDir = $dir; $r->gitDir = $this->gitDir . '/' . $n . '.git/'; - mkdir($r->gitDir, 0777);//FIXME + mkdir($r->gitDir, fileperms($this->gitDir) & 0777); return $r; } @@ -65,7 +67,16 @@ class Repositories $repos = array(); foreach ($some as $oneDir) { $r = new Repository(); - $r->loadById(substr($oneDir, 0, -4)); + try { + $r->loadById(substr($oneDir, 0, -4)); + } catch (\VersionControl_Git_Exception $e) { + if (strpos($e->getMessage(), 'does not have any commits') !== false) { + //the git repo is broken as the initial commit + // has not been finished + continue; + } + throw $e; + } $repos[] = $r; } return array($repos, count($dirs), $page);