Do not crash when a repo has a detached HEAD

Instead, we select a default branch - master by default, but the default
branch can be configured using config.ini.

Note that if the default branch does not exist in a repo, that should
not cause any issues.

Also adds phpunit to composer.json's require-dev section.
This commit is contained in:
Nate Eagleson
2013-02-14 22:31:47 -05:00
parent 6e4e8912b0
commit dabf4d86d9
9 changed files with 747 additions and 111 deletions

View File

@@ -95,6 +95,16 @@ class InterfaceTest extends WebTestCase
$repository->setConfig('user.email', 'luke@rebel.org');
$repository->addAll();
$repository->commit("Initial commit");
// Detached HEAD repository fixture
$git->createRepository(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');
}
public function createApplication()
@@ -126,8 +136,8 @@ class InterfaceTest extends WebTestCase
$this->assertEquals('/nested/NestedRepo/master/rss/', $crawler->filter('.repository-header a')->eq(3)->attr('href'));
$this->assertCount(1, $crawler->filter('div.repository-header:contains("foobar")'));
$this->assertCount(1, $crawler->filter('div.repository-body:contains("This is a test repo!")'));
$this->assertEquals('/foobar/', $crawler->filter('.repository-header a')->eq(6)->attr('href'));
$this->assertEquals('/foobar/master/rss/', $crawler->filter('.repository-header a')->eq(7)->attr('href'));
$this->assertEquals('/foobar/', $crawler->filter('.repository-header a')->eq(8)->attr('href'));
$this->assertEquals('/foobar/master/rss/', $crawler->filter('.repository-header a')->eq(9)->attr('href'));
}
public function testRepositoryPage()