mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 03:30:55 +01:00
Merge pull request #564 from mrzechonek/project_list
Add support for gitweb-style projects.list
This commit is contained in:
@@ -48,6 +48,9 @@ class Application extends SilexApplication
|
|||||||
));
|
));
|
||||||
|
|
||||||
$repositories = $config->get('git', 'repositories');
|
$repositories = $config->get('git', 'repositories');
|
||||||
|
$this['git.projects'] = $config->get('git', 'project_list') ?
|
||||||
|
$this->parseProjectList($config->get('git', 'project_list')) :
|
||||||
|
false;
|
||||||
|
|
||||||
$this->register(new GitServiceProvider(), array(
|
$this->register(new GitServiceProvider(), array(
|
||||||
'git.client' => $config->get('git', 'client'),
|
'git.client' => $config->get('git', 'client'),
|
||||||
@@ -153,4 +156,14 @@ class Application extends SilexApplication
|
|||||||
. 'twig'
|
. 'twig'
|
||||||
. DIRECTORY_SEPARATOR;
|
. DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function parseProjectList($project_list)
|
||||||
|
{
|
||||||
|
$projects = array();
|
||||||
|
$file = fopen($project_list, "r");
|
||||||
|
while ($file && !feof($file))
|
||||||
|
$projects[] = trim(fgets($file));
|
||||||
|
fclose($file);
|
||||||
|
return $projects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ class Client extends BaseClient
|
|||||||
{
|
{
|
||||||
protected $defaultBranch;
|
protected $defaultBranch;
|
||||||
protected $hidden;
|
protected $hidden;
|
||||||
|
protected $projects;
|
||||||
|
|
||||||
public function __construct($options = null)
|
public function __construct($options = null)
|
||||||
{
|
{
|
||||||
parent::__construct($options['path']);
|
parent::__construct($options['path']);
|
||||||
$this->setDefaultBranch($options['default_branch']);
|
$this->setDefaultBranch($options['default_branch']);
|
||||||
$this->setHidden($options['hidden']);
|
$this->setHidden($options['hidden']);
|
||||||
|
$this->setProjects($options['projects']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRepositoryFromName($paths, $repo)
|
public function getRepositoryFromName($paths, $repo)
|
||||||
@@ -102,6 +104,10 @@ class Client extends BaseClient
|
|||||||
$repoName = $file->getFilename();
|
$repoName = $file->getFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_array($this->getProjects()) && !in_array($repoName, $this->getProjects())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$repositories[$repoName] = array(
|
$repositories[$repoName] = array(
|
||||||
'name' => $repoName,
|
'name' => $repoName,
|
||||||
'path' => $file->getPathname(),
|
'path' => $file->getPathname(),
|
||||||
@@ -162,6 +168,28 @@ class Client extends BaseClient
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get project list
|
||||||
|
*
|
||||||
|
* @return array List of repositories to show
|
||||||
|
*/
|
||||||
|
protected function getProjects()
|
||||||
|
{
|
||||||
|
return $this->projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the shown repository list
|
||||||
|
*
|
||||||
|
* @param array $projects List of repositories to show
|
||||||
|
*/
|
||||||
|
protected function setProjects($projects)
|
||||||
|
{
|
||||||
|
$this->projects = $projects;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overloads the parent::createRepository method for the correct Repository class instance
|
* Overloads the parent::createRepository method for the correct Repository class instance
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class GitServiceProvider implements ServiceProviderInterface
|
|||||||
$app['git'] = function () use ($app) {
|
$app['git'] = function () use ($app) {
|
||||||
$options['path'] = $app['git.client'];
|
$options['path'] = $app['git.client'];
|
||||||
$options['hidden'] = $app['git.hidden'];
|
$options['hidden'] = $app['git.hidden'];
|
||||||
|
$options['projects'] = $app['git.projects'];
|
||||||
$options['ini.file'] = $app['ini.file'];
|
$options['ini.file'] = $app['ini.file'];
|
||||||
$options['default_branch'] = $app['git.default_branch'];
|
$options['default_branch'] = $app['git.default_branch'];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user