|
12 | 12 |
|
13 | 13 | namespace Gitonomy\Git\Tests;
|
14 | 14 |
|
| 15 | +use Gitonomy\Git\Parser\LogParser; |
| 16 | + |
15 | 17 | class LogTest extends AbstractTest
|
16 | 18 | {
|
17 | 19 | /**
|
@@ -91,4 +93,44 @@ public function testFirstMessageEmpty()
|
91 | 93 | $commits = $repository->getLog()->getCommits();
|
92 | 94 | $this->assertCount(1, $commits);
|
93 | 95 | }
|
| 96 | + |
| 97 | + public function testParsesCommitsWithAndWithoutGitButlerHeaders(): void |
| 98 | + { |
| 99 | + $logContent = <<<'EOT' |
| 100 | + commit 1111111111111111111111111111111111111111 |
| 101 | + tree abcdefabcdefabcdefabcdefabcdefabcdefabcd |
| 102 | + author John Doe <[email protected]> 1620000000 +0000 |
| 103 | + committer John Doe <[email protected]> 1620000000 +0000 |
| 104 | + |
| 105 | + First commit message |
| 106 | + |
| 107 | + commit 2222222222222222222222222222222222222222 |
| 108 | + tree abcdefabcdefabcdefabcdefabcdefabcdefabcd |
| 109 | + parent 1111111111111111111111111111111111111111 |
| 110 | + author Jane Smith <[email protected]> 1620003600 +0000 |
| 111 | + committer Jane Smith <[email protected]> 1620003600 +0000 |
| 112 | + gitbutler-headers-version: 2 |
| 113 | + gitbutler-change-id: a7bd485c-bae6-45b2-910f-163c78aace81 |
| 114 | + |
| 115 | + Commit with GitButler headers |
| 116 | + |
| 117 | + commit 3333333333333333333333333333333333333333 |
| 118 | + tree abcdefabcdefabcdefabcdefabcdefabcdefabcd |
| 119 | + author John Doe <[email protected]> 1620007200 +0000 |
| 120 | + committer Jane Smith <[email protected]> 1620007200 +0000 |
| 121 | + |
| 122 | + Another commit without GitButler headers |
| 123 | + |
| 124 | + EOT; |
| 125 | + |
| 126 | + $parser = new LogParser(); |
| 127 | + $parser->parse($logContent); |
| 128 | + |
| 129 | + $log = $parser->log; |
| 130 | + $this->assertCount(3, $log); |
| 131 | + |
| 132 | + $this->assertEquals("First commit message\n", $log[0]['message']); |
| 133 | + $this->assertEquals("Commit with GitButler headers\n", $log[1]['message']); |
| 134 | + $this->assertEquals("Another commit without GitButler headers\n", $log[2]['message']); |
| 135 | + } |
94 | 136 | }
|
0 commit comments