Major refactoring of the codebase, specially in the directory scanning parts.

I have removed the directory management features from Gitter and ported them to GitList,
since they are application-specific logic. I was unhappy with the way directories and multiple
directories were handled, so i altered almost everything.

The tests are OK, but the coverage is not good. This means that i'll need som help from all
GitList users that are actively testing the development version with multiple directories.

I have removed the directory caching feature for now, it will be re-implemented soon.
This commit is contained in:
Klaus Silveira
2013-06-01 12:51:25 -03:00
parent 5ed21119f6
commit 5122e91b49
17 changed files with 193 additions and 130 deletions

View File

@@ -2,13 +2,12 @@
use Silex\WebTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Gitter\Client;
use GitList\Git\Client;
class InterfaceTest extends WebTestCase
{
protected static $tmpdir;
protected static $gitPath;
protected static $cached_repos;
public static function setUpBeforeClass()
{
@@ -31,13 +30,11 @@ class InterfaceTest extends WebTestCase
$options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git';
$options['hidden'] = array(self::$tmpdir . '/hiddenrepo');
$options['default_branch'] = 'master';
$options['ini.file'] = "config.ini";
$cached_dir = self::$tmpdir . DIRECTORY_SEPARATOR . 'cache';
$fs->mkdir($cached_dir);
self::$cached_repos = $cached_dir . DIRECTORY_SEPARATOR . 'repos.json';
$options['cache.repos'] = self::$cached_repos;
$cacheDir = self::$tmpdir . DIRECTORY_SEPARATOR . 'cache';
$fs->mkdir($cacheDir);
$git = new Client($options);
@@ -45,7 +42,7 @@ class InterfaceTest extends WebTestCase
// GitTest repository fixture
$git->createRepository(self::$tmpdir . 'GitTest');
$repository = $git->getRepositoryCached(self::$tmpdir, 'GitTest');
$repository = $git->getRepository(self::$tmpdir . 'GitTest');
file_put_contents(self::$tmpdir . 'GitTest/README.md', "## GitTest\nGitTest is a *test* repository!");
file_put_contents(self::$tmpdir . 'GitTest/test.php', "<?php\necho 'Hello World'; // This is a test");
$repository->setConfig('user.name', 'Luke Skywalker');
@@ -58,7 +55,7 @@ class InterfaceTest extends WebTestCase
// foobar repository fixture
$git->createRepository(self::$tmpdir . 'foobar');
$repository = $git->getRepositoryCached(self::$tmpdir, 'foobar');
$repository = $git->getRepository(self::$tmpdir . 'foobar');
file_put_contents(self::$tmpdir . 'foobar/bar.json', "{\n\"name\": \"foobar\"\n}");
file_put_contents(self::$tmpdir . 'foobar/.git/description', 'This is a test repo!');
@@ -77,7 +74,7 @@ class InterfaceTest extends WebTestCase
$nested_dir = self::$tmpdir . 'nested/';
$fs->mkdir($nested_dir);
$git->createRepository($nested_dir . 'NestedRepo');
$repository = $git->getRepositoryCached($nested_dir, 'NestedRepo');
$repository = $git->getRepository($nested_dir . 'NestedRepo');
file_put_contents($nested_dir . 'NestedRepo/.git/description', 'This is a NESTED test repo!');
file_put_contents($nested_dir . 'NestedRepo/README.txt', 'NESTED TEST REPO README');
$repository->setConfig('user.name', 'Luke Skywalker');
@@ -93,7 +90,7 @@ class InterfaceTest extends WebTestCase
// master-less repository fixture
$git->createRepository(self::$tmpdir . 'develop');
$repository = $git->getRepositoryCached(self::$tmpdir, 'develop');
$repository = $git->getRepository(self::$tmpdir . 'develop');
$repository->setConfig('user.name', 'Luke Skywalker');
$repository->setConfig('user.email', 'luke@rebel.org');
file_put_contents(self::$tmpdir . 'develop/README.md', "## develop\ndevelop is a *test* repository!");
@@ -110,25 +107,23 @@ class InterfaceTest extends WebTestCase
// Detached HEAD repository fixture
$git->createRepository(self::$tmpdir . 'detached-head');
$repository = $git->getRepositoryCached(self::$tmpdir, 'detached-head');
# $repository = $git->getRepository(self::$tmpdir . '/detached-head');
$repository = $git->getRepository(self::$tmpdir . 'detached-head');
$repository->setConfig('user.name', 'Luke Skywalker');
$repository->setConfig('user.email', 'luke@rebel.org');
file_put_contents(self::$tmpdir . 'detached-head/README.md', "## detached head\ndetached-head is a *test* repository!");
$repository->addAll();
$repository->commit("First commit");
$repository->checkout('HEAD');
$git->deleteCached();
}
public function createApplication()
{
$config = GitList\Config::fromFile('config.ini');
$config->set('app', 'cached_repos', self::$cached_repos);
$config->set('git', 'repositories', self::$tmpdir);
$config = new GitList\Config;
$config->set('app', 'debug', true);
$config->set('app', 'debug', false);
$config->set('git', 'client', self::$gitPath);
$config->set('git', 'default_branch', 'master');
$config->set('git', 'repositories', array(self::$tmpdir));
$app = require 'boot.php';
return $app;