mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
Implementing hidden repository feature, fixes #30
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
[git]
|
[git]
|
||||||
client = '/usr/bin/git' ; Your git executable path
|
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]
|
[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
|
||||||
@@ -16,6 +16,7 @@ require_once __DIR__.'/vendor/silex.phar';
|
|||||||
$app = new Silex\Application();
|
$app = new Silex\Application();
|
||||||
$app['baseurl'] = $config['app']['baseurl'];
|
$app['baseurl'] = $config['app']['baseurl'];
|
||||||
$app['filetypes'] = $config['filetypes'];
|
$app['filetypes'] = $config['filetypes'];
|
||||||
|
$app['hidden'] = isset($config['git']['hidden']) ? $config['git']['hidden'] : array();
|
||||||
|
|
||||||
// Register Git and Twig libraries
|
// Register Git and Twig libraries
|
||||||
$app['autoloader']->registerNamespace('Git', __DIR__.'/lib');
|
$app['autoloader']->registerNamespace('Git', __DIR__.'/lib');
|
||||||
|
|||||||
@@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
namespace Git;
|
namespace Git;
|
||||||
|
|
||||||
|
use Silex\Application;
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
|
protected $app;
|
||||||
protected $path;
|
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);
|
$this->setPath($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +44,10 @@ class Client
|
|||||||
throw new \RuntimeException('There is no GIT repository at ' . $path);
|
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);
|
return new Repository($path, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +89,10 @@ class Client
|
|||||||
$isRepository = file_exists($file->getPathname() . '/.git/HEAD');
|
$isRepository = file_exists($file->getPathname() . '/.git/HEAD');
|
||||||
|
|
||||||
if ($file->isDir() && $isRepository || $isBare) {
|
if ($file->isDir() && $isRepository || $isBare) {
|
||||||
|
if (in_array($file->getPathname(), $this->app['hidden'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($isBare) {
|
if ($isBare) {
|
||||||
$description = $file->getPathname() . '/description';
|
$description = $file->getPathname() . '/description';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class GitServiceProvider implements ServiceProviderInterface
|
|||||||
public function register(Application $app)
|
public function register(Application $app)
|
||||||
{
|
{
|
||||||
$app['git'] = function () use ($app) {
|
$app['git'] = function () use ($app) {
|
||||||
$default = $app['git.client'] ? $app['git.client'] : '/usr/bin/git';
|
return new Client($app);
|
||||||
return new Client($app['git.client']);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user