From b644610438debb1a4e427fdff153cb5e7dcbfebe Mon Sep 17 00:00:00 2001 From: Wim Rijnders Date: Tue, 4 Dec 2012 06:29:10 +0100 Subject: [PATCH] Renamed getRepository() in gitter Client, to avoid method name collision; some code cleanup. --- index.php | 2 ++ src/GitList/Controller/MainController.php | 32 +++-------------------- src/GitList/Controller/TreeController.php | 17 ++++++------ 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/index.php b/index.php index 76807cb..be3f29f 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,6 @@ "; /** @@ -19,6 +20,7 @@ $config = GitList\Config::fromFile('config.ini'); $app = require 'boot.php'; +#WRI DEBUG echo ""; $app->run(); diff --git a/src/GitList/Controller/MainController.php b/src/GitList/Controller/MainController.php index 6bb5969..006b1fa 100644 --- a/src/GitList/Controller/MainController.php +++ b/src/GitList/Controller/MainController.php @@ -13,20 +13,7 @@ class MainController implements ControllerProviderInterface $route = $app['controllers_factory']; $route->get('/', function() use ($app) { -/* - $repositories = array_map( - function ($repo) use ($app) { - $repo['relativePath'] = $app['util.routing']->getRelativePath($repo['path']); - return $repo; - }, - $app['git']->getRepositories($app['git.repos']) - ); -*/ - $repositories = $app['git']->getRepositories($app['git.repos']); -echo "Doing that\n"; - #$repositories = $app['git.repos']; -print_r( $repositories ); return $app['twig']->render('index.twig', array( 'repositories' => $repositories, @@ -35,13 +22,8 @@ print_r( $repositories ); $route->get('{repo}/stats/{branch}', function($repo, $branch) 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); +echo "branches\n"; + $repository = $app['git']->getRepositoryCached($app['git.repos'], $repo); $stats = $repository->getStatistics($branch); $authors = $repository->getAuthorStatistics(); @@ -60,14 +42,8 @@ print_r( $repositories ); ->bind('stats'); $route->get('{repo}/{branch}/rss/', function($repo, $branch) use ($app) { - #$repository = $app['git']->getRepository($app['git.repos'] ); - - # 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); +echo "rss\n"; + $repository = $app['git']->getRepositoryCached($app['git.repos'], $repo); $commits = $repository->getPaginatedCommits($branch); diff --git a/src/GitList/Controller/TreeController.php b/src/GitList/Controller/TreeController.php index 1f50197..9d0efa4 100644 --- a/src/GitList/Controller/TreeController.php +++ b/src/GitList/Controller/TreeController.php @@ -15,12 +15,7 @@ class TreeController implements ControllerProviderInterface $route->get('{repo}/tree/{branch}/{tree}/', $treeController = function($repo, $branch = '', $tree = '') use ($app) { - # 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); + $repository = $app['git']->getRepositoryCached($app['git.repos'], $repo); if (!$branch) { $branch = $repository->getHead(); @@ -54,8 +49,12 @@ class TreeController implements ControllerProviderInterface ->bind('tree'); $route->post('{repo}/tree/{branch}/search', function(Request $request, $repo, $branch = '', $tree = '') use ($app) { - $repository = $app['git']->getRepository($app['git.repos'][ $repo ]); +echo "searc\n"; + $repository = $app['git']->getRepositoryCached($app['git.repos'], $repo); + $path = $repository->getPath(); + + $repository = $app['git']->getRepository($path ); if (!$branch) { $branch = $repository->getHead(); } @@ -88,7 +87,9 @@ class TreeController implements ControllerProviderInterface ->bind('repository'); $route->get('{repo}/{format}ball/{branch}', function($repo, $format, $branch) use ($app) { - $repository = $app['git']->getRepository($app['git.repos'] . $repo); + $repository = $app['git']->getRepositoryCached($app['git.repos'], $repo); + $path = $repository->getPath(); + $tree = $repository->getBranchTree($branch); if (false === $tree) {