diff --git a/config.ini-example b/config.ini-example index 70815f7..ce7571a 100644 --- a/config.ini-example +++ b/config.ini-example @@ -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' diff --git a/index.php b/index.php index be3f29f..0f46386 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,5 @@ "; - /** * 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 ""; - $app->run(); diff --git a/src/GitList/Config.php b/src/GitList/Config.php index 31bb07b..d7710b4 100644 --- a/src/GitList/Config.php +++ b/src/GitList/Config.php @@ -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"); + } } } diff --git a/src/GitList/Controller/BlobController.php b/src/GitList/Controller/BlobController.php index 9a44a27..e71674d 100644 --- a/src/GitList/Controller/BlobController.php +++ b/src/GitList/Controller/BlobController.php @@ -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(); diff --git a/src/GitList/Controller/CommitController.php b/src/GitList/Controller/CommitController.php index fd76805..ae10b6b 100644 --- a/src/GitList/Controller/CommitController.php +++ b/src/GitList/Controller/CommitController.php @@ -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); diff --git a/src/GitList/Controller/MainController.php b/src/GitList/Controller/MainController.php index 006b1fa..d7f0b05 100644 --- a/src/GitList/Controller/MainController.php +++ b/src/GitList/Controller/MainController.php @@ -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); diff --git a/src/GitList/Controller/TreeController.php b/src/GitList/Controller/TreeController.php index 97a10a6..7b92548 100644 --- a/src/GitList/Controller/TreeController.php +++ b/src/GitList/Controller/TreeController.php @@ -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(); diff --git a/src/GitList/Git/Client.php b/src/GitList/Git/Client.php index 8457bcf..94d476a 100644 --- a/src/GitList/Git/Client.php +++ b/src/GitList/Git/Client.php @@ -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); }