multiple dir's fully tested.

This commit is contained in:
Wim Rijnders
2012-12-20 20:56:10 +01:00
parent eb9e660f5b
commit ccdee643c6
8 changed files with 40 additions and 31 deletions

View File

@@ -2,6 +2,12 @@
client = '/usr/bin/git' ; Your git executable path
repositories = '/var/www/projects/' ; Path to your repositories
; If you want to specify multiple paths, use the array syntax instead:
;
;repositories[] = '/var/www/projects/'
;repositories[] = '/var/www/subdir/more_projects/'
;repositories[] = '/home/user/even_more_projects/'
; You can hide repositories from GitList, just copy this for each repository you want to hide
; hidden[] = '/var/www/projects/BetaTest'

View File

@@ -1,8 +1,5 @@
<?php
#WRI DEBUG
echo "<pre>";
/**
* GitList 0.3
* https://github.com/klaussilveira/gitlist
@@ -20,7 +17,4 @@ $config = GitList\Config::fromFile('config.ini');
$app = require 'boot.php';
#WRI DEBUG
echo "</pre>";
$app->run();

View File

@@ -49,11 +49,23 @@ class Config
protected function validateOptions()
{
$at_least_one_ok = false;
$at_least_one_wrong = false;
foreach ( $this->get('git', 'repositories') as $dir ) {
echo $dir;
if (!$dir || !is_dir($dir)) {
die("Please, edit the config file and provide your repositories directory");
$at_least_one_wrong = true;
} else {
$at_least_one_ok = true;
}
}
if ( !$at_least_one_ok ) {
die("Please, edit the config file and provide your repositories directory");
}
if ( $at_least_one_wrong ) {
die("One or more of the supplied repository paths appears to be wrong. Please, check the config file");
}
}
}

View File

@@ -13,7 +13,8 @@ class BlobController implements ControllerProviderInterface
$route = $app['controllers_factory'];
$route->get('{repo}/blob/{branch}/{file}', function($repo, $branch, $file) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
$blob = $repository->getBlob("$branch:\"$file\"");
@@ -44,7 +45,9 @@ class BlobController implements ControllerProviderInterface
->bind('blob');
$route->get('{repo}/raw/{branch}/{file}', function($repo, $branch, $file) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
$blob = $repository->getBlob("$branch:\"$file\"")->output();

View File

@@ -13,14 +13,8 @@ class CommitController implements ControllerProviderInterface
$route = $app['controllers_factory'];
$route->get('{repo}/commits/{branch}/{file}', function($repo, $branch, $file) use ($app) {
#$repository = $app['git']->getRepository($app['git.repos'] . $repo);
# NOTE: this call is to the ONE Client!
$repositories = $app['git']->getRepositories($app['git.repos']);
$path = $repositories[ $repo ]['path'];
# NOTE: this call is to the OTHER Client!
$repository = $app['git']->getRepository($path);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);
@@ -53,7 +47,9 @@ class CommitController implements ControllerProviderInterface
->bind('commits');
$route->post('{repo}/commits/search', function(Request $request, $repo) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
$commits = $repository->searchCommitLog($request->get('query'));
foreach ($commits as $commit) {
@@ -74,7 +70,9 @@ class CommitController implements ControllerProviderInterface
->bind('searchcommits');
$route->get('{repo}/commit/{commit}/', function($repo, $commit) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
$commit = $repository->getCommit($commit);
return $app['twig']->render('commit.twig', array(
@@ -87,7 +85,8 @@ class CommitController implements ControllerProviderInterface
->bind('commit');
$route->get('{repo}/blame/{branch}/{file}', function($repo, $branch, $file) use ($app) {
$repository = $app['git']->getRepository($app['git.repos'] . $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file);

View File

@@ -21,9 +21,9 @@ class MainController implements ControllerProviderInterface
})->bind('homepage');
$route->get('{repo}/stats/{branch}', function($repo, $branch) use ($app) {
#$repository = $app['git']->getRepository($app['git.repos'][$repo]);
echo "branches\n";
$repository = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
$stats = $repository->getStatistics($branch);
$authors = $repository->getAuthorStatistics();
@@ -42,8 +42,8 @@ echo "branches\n";
->bind('stats');
$route->get('{repo}/{branch}/rss/', function($repo, $branch) use ($app) {
echo "rss\n";
$repository = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repotmp = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$repository = $app['git']->getRepository($repotmp->getPath());
$commits = $repository->getPaginatedCommits($branch);

View File

@@ -49,7 +49,6 @@ class TreeController implements ControllerProviderInterface
->bind('tree');
$route->post('{repo}/tree/{branch}/search', function(Request $request, $repo, $branch = '', $tree = '') use ($app) {
echo "searc\n";
$repository = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$path = $repository->getPath();
@@ -79,8 +78,6 @@ echo "searc\n";
# WRI: Changed order of this and next statement, because order
# appears to be important, and the other statement got precedence
$route->get('{repo}/{format}ball/{branch}', function($repo, $format, $branch) use ($app) {
echo "tarball\n";
$repo_item = $app['git']->getRepositoryCached($app['git.repos'], $repo);
$path = $repo_item->getPath();

View File

@@ -31,8 +31,6 @@ class Client extends BaseClient
*/
public function getRepository($path)
{
echo "this getRepository2\n";
if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) {
throw new \RuntimeException('There is no GIT repository at ' . $path);
}