diff --git a/src/CommitMessage.php b/src/CommitMessage.php index f4be22a..0f500e1 100644 --- a/src/CommitMessage.php +++ b/src/CommitMessage.php @@ -111,6 +111,19 @@ public function isEmpty() : bool return empty($this->content); } + + /** + * Get commit message content + * + * This excludes lines that are comments. + * + * @return string + */ + public function getContent() : string + { + return $this->content; + } + /** * Get complete commit message content * @@ -118,7 +131,7 @@ public function isEmpty() : bool * * @return string */ - public function getContent() : string + public function getRawContent() : string { return $this->rawContent; } diff --git a/tests/git/CommitMessageTest.php b/tests/git/CommitMessageTest.php index 6bdffe5..81f035a 100644 --- a/tests/git/CommitMessageTest.php +++ b/tests/git/CommitMessageTest.php @@ -37,6 +37,9 @@ public function testIsEmptyDoesNotIncludeComments() $this->assertTrue($msg->isEmpty()); } + /** + * Tests CommitMessage::getContent + */ public function testGetContent() { $content = 'Foo' . PHP_EOL . 'Bar' . PHP_EOL . 'Baz'; @@ -44,11 +47,25 @@ public function testGetContent() $this->assertEquals($content, $msg->getContent()); } - public function testGetContentIncludesComments() + + /** + * Tests CommitMessage::getContent + */ + public function testGetContentExcludesComments() + { + $content = 'Foo' . PHP_EOL . '# Bar' . PHP_EOL . 'Baz'; + $msg = new CommitMessage($content, '#'); + $this->assertEquals('Foo' . PHP_EOL . 'Baz', $msg->getContent()); + } + + /** + * Tests CommitMessage::getRawContent + */ + public function testGetRawContentIncludesComments() { $content = 'Foo' . PHP_EOL . '# Bar' . PHP_EOL . 'Baz'; $msg = new CommitMessage($content,'#'); - $this->assertEquals($content, $msg->getContent()); + $this->assertEquals($content, $msg->getRawContent()); } /**