Skip to content

Commit

Permalink
Change 'getContent' to not return comments
Browse files Browse the repository at this point in the history
Instead make use of the new 'getRawContent' method to
retrieve the content including the comments.
  • Loading branch information
sebastianfeldmann committed Apr 22, 2017
1 parent 845bb87 commit 7fbf226
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/CommitMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,27 @@ 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
*
* This includes lines that are comments.
*
* @return string
*/
public function getContent() : string
public function getRawContent() : string
{
return $this->rawContent;
}
Expand Down
21 changes: 19 additions & 2 deletions tests/git/CommitMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,35 @@ public function testIsEmptyDoesNotIncludeComments()
$this->assertTrue($msg->isEmpty());
}

/**
* Tests CommitMessage::getContent
*/
public function testGetContent()
{
$content = 'Foo' . PHP_EOL . 'Bar' . PHP_EOL . 'Baz';
$msg = new CommitMessage($content);
$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());
}

/**
Expand Down

0 comments on commit 7fbf226

Please sign in to comment.