From 707517859ac61fa7faad93f182974acfd0f7d1af Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sun, 1 Mar 2015 17:35:09 +1100 Subject: [PATCH 1/2] Use mailmap-respecting author/committer placeholders --- src/GitList/Git/Repository.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/GitList/Git/Repository.php b/src/GitList/Git/Repository.php index d04f987..58338fb 100644 --- a/src/GitList/Git/Repository.php +++ b/src/GitList/Git/Repository.php @@ -45,8 +45,8 @@ class Repository extends BaseRepository $logs = $this->getClient()->run($this, "show --pretty=format:\"%H" . "%h%T%P" - . "%an%ae" - . "%at%cn%ce" + . "%aN%aE" + . "%at%cN%cE" . "%ct" . "" . "" @@ -213,9 +213,9 @@ class Repository extends BaseRepository $command = "log $pager --pretty=format:\"%H" . "%h%T%P" - . "%an%ae" - . "%at%cn" - . "%ce" + . "%aN%aE" + . "%at%cN" + . "%cE" . "%ct" . "\""; @@ -245,9 +245,9 @@ class Repository extends BaseRepository $command = "log --grep={$query} -i --pretty=format:\"%H" . "%h%T%P" - . "%an%ae" - . "%at%cn" - . "%ce" + . "%aN%aE" + . "%at%cN" + . "%cE" . "%ct" . "\"" . " $branch"; @@ -299,7 +299,7 @@ class Repository extends BaseRepository public function getAuthorStatistics($branch) { - $logs = $this->getClient()->run($this, 'log --pretty=format:"%an||%ae" ' . $branch); + $logs = $this->getClient()->run($this, 'log --pretty=format:"%aN||%aE" ' . $branch); if (empty($logs)) { throw new \RuntimeException('No statistics available'); From a5110d597cecaaeb60cdb18af4a31f1422ce3714 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Sun, 1 Mar 2015 18:22:49 +1100 Subject: [PATCH 2/2] Test case for mailmap --- tests/InterfaceTest.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/InterfaceTest.php b/tests/InterfaceTest.php index 2c2cd8c..e0d6b68 100644 --- a/tests/InterfaceTest.php +++ b/tests/InterfaceTest.php @@ -114,6 +114,16 @@ class InterfaceTest extends WebTestCase $repository->addAll(); $repository->commit("First commit"); $repository->checkout('HEAD'); + + // mailmap repository fixture + $git->createRepository(self::$tmpdir . 'mailmap'); + $repository = $git->getRepository(self::$tmpdir . 'mailmap'); + $repository->setConfig('user.name', 'Luke Skywalker'); + $repository->setConfig('user.email', 'luke@rebel.org'); + file_put_contents(self::$tmpdir . 'mailmap/README.md', "## mailmap\nmailmap is a *test* repository!"); + file_put_contents(self::$tmpdir . 'mailmap/.mailmap', "Anakin Skywalker Luke Skywalker "); + $repository->addAll(); + $repository->commit("First commit"); } public function createApplication() @@ -157,9 +167,13 @@ class InterfaceTest extends WebTestCase $this->assertEquals('/GitTest/', $crawler->filter('.repository-header a')->eq(6)->attr('href')); $this->assertEquals('/GitTest/master/rss/', $crawler->filter('.repository-header a')->eq(7)->attr('href')); + $this->assertCount(1, $crawler->filter('div.repository-header a:contains("mailmap")')); + $this->assertEquals('/mailmap/', $crawler->filter('.repository-header a')->eq(8)->attr('href')); + $this->assertEquals('/mailmap/master/rss/', $crawler->filter('.repository-header a')->eq(9)->attr('href')); + $this->assertCount(1, $crawler->filter('div.repository-header a:contains("nested/NestedRepo")')); - $this->assertEquals('/nested/NestedRepo/', $crawler->filter('.repository-header a')->eq(8)->attr('href')); - $this->assertEquals('/nested/NestedRepo/master/rss/', $crawler->filter('.repository-header a')->eq(9)->attr('href')); + $this->assertEquals('/nested/NestedRepo/', $crawler->filter('.repository-header a')->eq(10)->attr('href')); + $this->assertEquals('/nested/NestedRepo/master/rss/', $crawler->filter('.repository-header a')->eq(11)->attr('href')); $this->assertCount(1, $crawler->filter('div.repository-body:contains("This is a NESTED test repo!")')); } @@ -265,6 +279,11 @@ class InterfaceTest extends WebTestCase $crawler = $client->request('GET', '/foobar/commits/master/bar.json'); $this->assertTrue($client->getResponse()->isOk()); $this->assertEquals('First commit', $crawler->filter('.table tbody tr td h4')->eq(0)->text()); + + $crawler = $client->request('GET', '/mailmap/commits/master/README.md'); + $this->assertTrue($client->getResponse()->isOk()); + $this->assertEquals('Anakin Skywalker', $crawler->filter('.table tbody tr td span a')->eq(1)->text()); + $this->assertEquals('mailto:darth@empire.com', $crawler->filter('.table tbody tr td span a')->eq(1)->attr('href')); } /** @@ -281,6 +300,11 @@ class InterfaceTest extends WebTestCase $crawler = $client->request('GET', '/foobar/commits'); $this->assertTrue($client->getResponse()->isOk()); $this->assertEquals('First commit', $crawler->filter('.table tbody tr td h4')->eq(0)->text()); + + $crawler = $client->request('GET', '/mailmap/commits'); + $this->assertTrue($client->getResponse()->isOk()); + $this->assertEquals('Anakin Skywalker', $crawler->filter('.table tbody tr td span a')->eq(1)->text()); + $this->assertEquals('mailto:darth@empire.com', $crawler->filter('.table tbody tr td span a')->eq(1)->attr('href')); } /** @@ -296,6 +320,10 @@ class InterfaceTest extends WebTestCase $this->assertRegexp('/.md: 1 files/', $crawler->filter('.table tbody')->eq(0)->text()); $this->assertRegexp('/Total files: 2/', $crawler->filter('.table tbody')->eq(0)->text()); $this->assertRegexp('/Luke Skywalker: 1 commits/', $crawler->filter('.table tbody')->eq(0)->text()); + + $crawler = $client->request('GET', '/mailmap/stats'); + $this->assertTrue($client->getResponse()->isOk()); + $this->assertRegexp('/Anakin Skywalker: 1 commits/', $crawler->filter('.table tbody')->eq(0)->text()); } /**