diff --git a/config.ini-example b/config.ini-example index 186c20d..0684768 100644 --- a/config.ini-example +++ b/config.ini-example @@ -1,6 +1,14 @@ [git] client = '/usr/bin/git' ; Your git executable path -repositories = '/home/git/' ; Path to your repositories (with ending slash) +repositories = '/var/www/projects/' ; Path to your repositories (with ending slash) + +; You can hide repositories from GitList, just copy this for each repository you want to hide +; hidden[] = '/var/www/projects/BetaTest' [app] -baseurl = 'http://localhost/gitlist' ; Base URL of the application (without ending slash) +baseurl = 'http://localhost/git' ; Base URL of the application (without ending slash) + +; If you need to specify custom filetypes for certain extensions, do this here +[filetypes] +; extension = type +; dist = xml \ No newline at end of file diff --git a/index.php b/index.php index a2d1e8a..5ef54ef 100644 --- a/index.php +++ b/index.php @@ -16,6 +16,7 @@ require_once __DIR__.'/vendor/silex.phar'; $app = new Silex\Application(); $app['baseurl'] = $config['app']['baseurl']; $app['filetypes'] = $config['filetypes']; +$app['hidden'] = isset($config['git']['hidden']) ? $config['git']['hidden'] : array(); // Register Git and Twig libraries $app['autoloader']->registerNamespace('Git', __DIR__.'/lib'); diff --git a/lib/Git/Client.php b/lib/Git/Client.php index f24057b..252e636 100644 --- a/lib/Git/Client.php +++ b/lib/Git/Client.php @@ -2,12 +2,17 @@ namespace Git; +use Silex\Application; + class Client { + protected $app; protected $path; - public function __construct($path) + public function __construct(Application $app) { + $this->app = $app; + $path = $this->app['git.client'] ? $this->app['git.client'] : '/usr/bin/git'; $this->setPath($path); } @@ -39,6 +44,10 @@ class Client throw new \RuntimeException('There is no GIT repository at ' . $path); } + if (in_array($path, $this->app['hidden'])) { + throw new \RuntimeException('You don\'t have access to this repository'); + } + return new Repository($path, $this); } @@ -80,6 +89,10 @@ class Client $isRepository = file_exists($file->getPathname() . '/.git/HEAD'); if ($file->isDir() && $isRepository || $isBare) { + if (in_array($file->getPathname(), $this->app['hidden'])) { + continue; + } + if ($isBare) { $description = $file->getPathname() . '/description'; } else { diff --git a/lib/Git/GitServiceProvider.php b/lib/Git/GitServiceProvider.php index 1e8ab6d..558915e 100644 --- a/lib/Git/GitServiceProvider.php +++ b/lib/Git/GitServiceProvider.php @@ -16,8 +16,7 @@ class GitServiceProvider implements ServiceProviderInterface public function register(Application $app) { $app['git'] = function () use ($app) { - $default = $app['git.client'] ? $app['git.client'] : '/usr/bin/git'; - return new Client($app['git.client']); + return new Client($app); }; } } \ No newline at end of file