Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Edge case: Empty message in the first commit (#217)
Don't try to consume a 2nd new line when the first repository
commit has an empty message.
  • Loading branch information
claudiu-cristea committed May 7, 2024
commit b9175ecb9a80e08242350b4ff8fa6e5e26dd3d23
4 changes: 3 additions & 1 deletion src/Gitonomy/Git/Parser/LogParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ protected function doParse()
$this->consumeGPGSignature();

$this->consumeNewLine();
$this->consumeNewLine();
if ($this->cursor < strlen($this->content)) {
$this->consumeNewLine();
}

$message = '';
if ($this->expects(' ')) {
Expand Down
10 changes: 10 additions & 0 deletions tests/Gitonomy/Git/Tests/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,14 @@ public function testIterable($repository)
}
}
}

public function testFirstMessageEmpty()
{
$repository = $this->createEmptyRepository(false);
file_put_contents($repository->getWorkingDir().'/file', 'foo');
$repository->run('add', ['.']);
$repository->run('commit', ['--allow-empty-message', '--no-edit']);
$commits = $repository->getLog()->getCommits();
$this->assertCount(1, $commits);
}
}