diff --git a/boot.php b/boot.php index a7336b2..ab4ac76 100644 --- a/boot.php +++ b/boot.php @@ -18,16 +18,18 @@ foreach( $repositories as $repo ) { } $repositories = $tmp_arr; -$config->set('git', 'repositories', $repositories); // Startup and configure Silex application $app = new GitList\Application($config, __DIR__); + // Mount the controllers $app->mount('', new GitList\Controller\MainController()); $app->mount('', new GitList\Controller\BlobController()); $app->mount('', new GitList\Controller\CommitController()); $app->mount('', new GitList\Controller\TreeController()); + + return $app; diff --git a/src/GitList/Application.php b/src/GitList/Application.php index 7f7e2cd..353b238 100644 --- a/src/GitList/Application.php +++ b/src/GitList/Application.php @@ -37,9 +37,17 @@ class Application extends SilexApplication 'twig.path' => $root . DIRECTORY_SEPARATOR . 'views', 'twig.options' => array('cache' => $root . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'views'), )); + + $repositories = $config->get('git', 'repositories'); +/* + echo "doing this\n"; + $repositories = $app['git']->getRepositories($repositories); + $config->set('git', 'repositories', $repositories); +*/ + $this->register(new GitServiceProvider(), array( 'git.client' => $config->get('git', 'client'), - 'git.repos' => $config->get('git', 'repositories'), + 'git.repos' => $repositories, 'git.hidden' => $config->get('git', 'hidden') ? $config->get('git', 'hidden') : array(), )); $this->register(new ViewUtilServiceProvider()); diff --git a/src/GitList/Controller/CommitController.php b/src/GitList/Controller/CommitController.php index 776f669..fd76805 100644 --- a/src/GitList/Controller/CommitController.php +++ b/src/GitList/Controller/CommitController.php @@ -13,7 +13,14 @@ 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); + #$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); 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 b99fafd..6bb5969 100644 --- a/src/GitList/Controller/MainController.php +++ b/src/GitList/Controller/MainController.php @@ -24,6 +24,9 @@ class MainController implements ControllerProviderInterface */ $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, @@ -32,7 +35,14 @@ class MainController implements ControllerProviderInterface $route->get('{repo}/stats/{branch}', function($repo, $branch) use ($app) { #$repository = $app['git']->getRepository($app['git.repos'][$repo]); - $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); + $stats = $repository->getStatistics($branch); $authors = $repository->getAuthorStatistics(); @@ -50,7 +60,15 @@ class MainController implements ControllerProviderInterface ->bind('stats'); $route->get('{repo}/{branch}/rss/', function($repo, $branch) use ($app) { - $repository = $app['git']->getRepository($app['git.repos'] . $repo); + #$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); + $commits = $repository->getPaginatedCommits($branch); $html = $app['twig']->render('rss.twig', array( diff --git a/src/GitList/Controller/TreeController.php b/src/GitList/Controller/TreeController.php index fe463b7..1f50197 100644 --- a/src/GitList/Controller/TreeController.php +++ b/src/GitList/Controller/TreeController.php @@ -14,7 +14,14 @@ class TreeController implements ControllerProviderInterface $route = $app['controllers_factory']; $route->get('{repo}/tree/{branch}/{tree}/', $treeController = function($repo, $branch = '', $tree = '') 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); + if (!$branch) { $branch = $repository->getHead(); } @@ -39,7 +46,7 @@ class TreeController implements ControllerProviderInterface 'breadcrumbs' => $breadcrumbs, 'branches' => $repository->getBranches(), 'tags' => $repository->getTags(), - 'readme' => $app['util.repository']->getReadme($repo, $branch), + 'readme' => $app['util.repository']->getReadme($repository, $branch), )); })->assert('repo', $app['util.routing']->getRepositoryRegex()) ->assert('branch', '[\w-._\/]+') @@ -47,7 +54,7 @@ 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); + $repository = $app['git']->getRepository($app['git.repos'][ $repo ]); if (!$branch) { $branch = $repository->getHead(); diff --git a/src/GitList/Git/Client.php b/src/GitList/Git/Client.php index 94d476a..8457bcf 100644 --- a/src/GitList/Git/Client.php +++ b/src/GitList/Git/Client.php @@ -31,6 +31,8 @@ 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); } diff --git a/src/GitList/Util/Repository.php b/src/GitList/Util/Repository.php index e158b95..c1ea2b7 100644 --- a/src/GitList/Util/Repository.php +++ b/src/GitList/Util/Repository.php @@ -160,9 +160,9 @@ class Repository return false; } - public function getReadme($repo, $branch = 'master') + public function getReadme($repository, $branch = 'master') { - $repository = $this->app['git']->getRepository($this->app['git.repos'] . $repo); + #$repository = $this->app['git']->getRepository($this->app['git.repos'][$repo ]); $files = $repository->getTree($branch)->output(); foreach ($files as $file) { diff --git a/src/GitList/Util/Routing.php b/src/GitList/Util/Routing.php index f729435..28724e8 100644 --- a/src/GitList/Util/Routing.php +++ b/src/GitList/Util/Routing.php @@ -23,8 +23,9 @@ class Routing #function ($repo) use ($app) { # return preg_quote($app['util.routing']->getRelativePath($repo['path']), '#'); #}, + # TODO: return keys instead function ($repo) use ($app) { - return $repo['path']; + return $repo['name']; }, $this->app['git']->getRepositories($this->app['git.repos']) ); diff --git a/views/index.twig b/views/index.twig index 07093cd..db725ac 100644 --- a/views/index.twig +++ b/views/index.twig @@ -9,8 +9,8 @@ {% for repository in repositories %}
{{ repository.description }}