mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-17 19:20:56 +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');
|
||||
$this['git.projects'] = $config->get('git', 'project_list') ?
|
||||
$this->parseProjectList($config->get('git', 'project_list')) :
|
||||
false;
|
||||
|
||||
$this->register(new GitServiceProvider(), array(
|
||||
'git.client' => $config->get('git', 'client'),
|
||||
@@ -153,4 +156,14 @@ class Application extends SilexApplication
|
||||
. 'twig'
|
||||
. 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 $hidden;
|
||||
protected $projects;
|
||||
|
||||
public function __construct($options = null)
|
||||
{
|
||||
parent::__construct($options['path']);
|
||||
$this->setDefaultBranch($options['default_branch']);
|
||||
$this->setHidden($options['hidden']);
|
||||
$this->setProjects($options['projects']);
|
||||
}
|
||||
|
||||
public function getRepositoryFromName($paths, $repo)
|
||||
@@ -102,6 +104,10 @@ class Client extends BaseClient
|
||||
$repoName = $file->getFilename();
|
||||
}
|
||||
|
||||
if (is_array($this->getProjects()) && !in_array($repoName, $this->getProjects())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$repositories[$repoName] = array(
|
||||
'name' => $repoName,
|
||||
'path' => $file->getPathname(),
|
||||
@@ -162,6 +168,28 @@ class Client extends BaseClient
|
||||
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
|
||||
*
|
||||
|
||||
@@ -20,6 +20,7 @@ class GitServiceProvider implements ServiceProviderInterface
|
||||
$app['git'] = function () use ($app) {
|
||||
$options['path'] = $app['git.client'];
|
||||
$options['hidden'] = $app['git.hidden'];
|
||||
$options['projects'] = $app['git.projects'];
|
||||
$options['ini.file'] = $app['ini.file'];
|
||||
$options['default_branch'] = $app['git.default_branch'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user