Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 0a9ded5 + 179aeef commit 52201e6172d7c6511c123925cb0c5dc19886f023 @lukx lukx committed Jun 6, 2013
View
@@ -31,3 +31,4 @@ node_modules
config.ini
cache.properties
composer.phar
+phpunit.xml
View
@@ -1,13 +1,5 @@
<?php
-if (!isset($config)) {
- die("No configuration object provided.");
-}
-
-if (!is_writable(__DIR__ . DIRECTORY_SEPARATOR . 'cache')) {
- die(sprintf('The "%s" folder must be writable for GitList to run.', __DIR__ . DIRECTORY_SEPARATOR . 'cache'));
-}
-
// Startup and configure Silex application
$app = new GitList\Application($config, __DIR__);
View
@@ -4,7 +4,7 @@
"twig/twig": "1.12.*",
"symfony/twig-bridge": "2.2.*",
"symfony/filesystem": "2.2.*",
- "klaussilveira/gitter": "dev-master"
+ "klaussilveira/gitter": "0.2.*"
},
"require-dev": {
"symfony/browser-kit": "2.2.*",
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,26 +1,19 @@
[git]
client = '/usr/bin/git' ; Your git executable path
-repositories = '/var/www/projects/' ; Path to your repositories
default_branch = 'master' ; Default branch when HEAD is detached
+repositories[] = '/home/git/repositories/' ; Path to your repositories
+ ; If you wish to add more repositories, just add a new line
-
-;Windows Users
+; WINDOWS USERS
;client = '"C:\Program Files (x86)\Git\bin\git.exe"' ; Your git executable path
-;repositories = 'C:\Path\to\Repos\' ; 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/'
-
+;repositories[] = 'C:\Path\to\Repos\' ; Path to your repositories
; You can hide repositories from GitList, just copy this for each repository you want to hide
-; hidden[] = '/var/www/projects/BetaTest'
+; hidden[] = '/home/git/repositories/BetaTest'
[app]
debug = false
+cache = true
; If you need to specify custom filetypes for certain extensions, do this here
[filetypes]
View
@@ -14,12 +14,13 @@
return false;
}
+if (!is_writable(__DIR__ . DIRECTORY_SEPARATOR . 'cache')) {
+ die(sprintf('The "%s" folder must be writable for GitList to run.', __DIR__ . DIRECTORY_SEPARATOR . 'cache'));
+}
+
require 'vendor/autoload.php';
-// Load configuration
$config = GitList\Config::fromFile('config.ini');
-
$app = require 'boot.php';
-
$app->run();
@@ -36,23 +36,20 @@ public function __construct(Config $config, $root = null)
// Register services
$this->register(new TwigServiceProvider(), array(
'twig.path' => $this->getViewPath(),
- 'twig.options' => array('cache' => $this->getCachePath() . 'views'),
+ 'twig.options' => $config->get('app', 'cache') ?
+ array('cache' => $this->getCachePath() . 'views') : array(),
));
$repositories = $config->get('git', 'repositories');
- $repositoryCache = $config->get('app', 'cached_repos');
- if (false === $repositoryCache || empty($repositoryCache)) {
- $repositoryCache = $this->getCachePath() . 'repos.json';
- }
$this->register(new GitServiceProvider(), array(
- 'git.client' => $config->get('git', 'client'),
- 'git.repos' => $repositories,
- 'cache.repos' => $repositoryCache,
- 'ini.file' => "config.ini",
- 'git.hidden' => $config->get('git', 'hidden') ?
- $config->get('git', 'hidden') : array(),
- 'git.default_branch' => $config->get('git', 'default_branch') ? $config->get('git', 'default_branch') : 'master',
+ 'git.client' => $config->get('git', 'client'),
+ 'git.repos' => $repositories,
+ 'ini.file' => "config.ini",
+ 'git.hidden' => $config->get('git', 'hidden') ?
+ $config->get('git', 'hidden') : array(),
+ 'git.default_branch' => $config->get('git', 'default_branch') ?
+ $config->get('git', 'default_branch') : 'master',
));
$this->register(new ViewUtilServiceProvider());
@@ -100,4 +97,3 @@ public function getViewPath()
return $this->path . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR;
}
}
-
View
@@ -13,19 +13,15 @@ public static function fromFile($file)
}
$data = parse_ini_file($file, true);
-
- # Ensure that repositories item is an array
- if (!is_array($data['git']['repositories'])) {
- $data['git']['repositories'] = array($data['git']['repositories']);
- }
+ $config = new static($data);
+ $config->validateOptions();
- return new static($data);
+ return $config;
}
- public function __construct($data)
+ public function __construct($data = array())
{
$this->data = $data;
- $this->validateOptions();
}
public function get($section, $option)
@@ -59,10 +55,6 @@ protected function validateOptions()
{
$repositories = $this->get('git', 'repositories');
- if (!is_array($repositories)) {
- return;
- }
-
$atLeastOneOk = false;
$atLeastOneWrong = false;
@@ -13,7 +13,7 @@ public function connect(Application $app)
$route = $app['controllers_factory'];
$route->get('{repo}/blob/{commitishPath}', function ($repo, $commitishPath) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitishPath, $repo);
@@ -46,7 +46,7 @@ public function connect(Application $app)
->bind('blob');
$route->get('{repo}/raw/{commitishPath}', function ($repo, $commitishPath) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitishPath, $repo);
@@ -13,7 +13,7 @@ public function connect(Application $app)
$route = $app['controllers_factory'];
$route->get('{repo}/commits/{commitishPath}', function ($repo, $commitishPath) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
if ($commitishPath === null) {
$commitishPath = $repository->getHead();
@@ -53,7 +53,7 @@ public function connect(Application $app)
->bind('commits');
$route->post('{repo}/commits/{branch}/search', function (Request $request, $repo, $branch = '') use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
$query = $request->get('query');
$commits = $repository->searchCommitLog($request->get('query'));
@@ -79,7 +79,7 @@ public function connect(Application $app)
->bind('searchcommits');
$route->get('{repo}/commit/{commit}', function ($repo, $commit) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
$commit = $repository->getCommit($commit);
$branch = $repository->getHead();
@@ -93,7 +93,7 @@ public function connect(Application $app)
->bind('commit');
$route->get('{repo}/blame/{commitishPath}', function ($repo, $commitishPath) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
list($branch, $file) = $app['util.routing']
->parseCommitishPathParam($commitishPath, $repo);
@@ -23,15 +23,12 @@ public function connect(Application $app)
$route->get('/refresh', function(Request $request) use ($app ) {
- $app['git']->deleteCached();
-
# Go back to calling page
return $app->redirect($request->headers->get('Referer'));
})->bind('refresh');
-
$route->get('{repo}/stats/{branch}', function($repo, $branch) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
if ($branch === null) {
$branch = $repository->getHead();
@@ -54,7 +51,7 @@ public function connect(Application $app)
->bind('stats');
$route->get('{repo}/{branch}/rss/', function($repo, $branch) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
if ($branch === null) {
$branch = $repository->getHead();
@@ -77,4 +74,3 @@ public function connect(Application $app)
return $route;
}
}
-
@@ -14,7 +14,7 @@ public function connect(Application $app)
$route = $app['controllers_factory'];
$route->get('{repo}/tree/{commitishPath}/', $treeController = function ($repo, $commitishPath = '') use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
if (!$commitishPath) {
$commitishPath = $repository->getHead();
}
@@ -48,7 +48,7 @@ public function connect(Application $app)
->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']->getRepositoryFromName($app['git.repos'], $repo);
if (!$branch) {
$branch = $repository->getHead();
}
@@ -74,7 +74,7 @@ public function connect(Application $app)
# Intentionally before next statement, because order appears
# to be important, and the other statement got precedence previously.
$route->get('{repo}/{format}ball/{branch}', function($repo, $format, $branch) use ($app) {
- $repository = $app['git']->getRepository($app['git.repos'], $repo);
+ $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
$tree = $repository->getBranchTree($branch);
Oops, something went wrong.

0 comments on commit 52201e6

Please sign in to comment.