Skip to content

Commit

Permalink
Merge pull request #8 from christofdamian/allow-leading-whitespace
Browse files Browse the repository at this point in the history
allow leading whitespace
  • Loading branch information
christofdamian committed Jul 28, 2015
2 parents 204647f + cad057d commit fb10294
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGES
=======

0.5.8
-----
* allow leading whitespace

0.5.7
-----
* Reverse PR order (again)
Expand Down
6 changes: 3 additions & 3 deletions src/PlusPull/GitHub/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function checkComments($required = 3, $whitelist = null)

public function isBlocker($commentBody)
{
return preg_match('/^\[B\]/', $commentBody);
return preg_match('/^\s*\[B\]/', $commentBody);
}

public function getCommentValue($commentBody)
{
if (preg_match('/^(\+1\b|:\+1:)/', $commentBody)) {
if (preg_match('/^\s*(\+1\b|:\+1:)/', $commentBody)) {
return 1;
}
if (preg_match('/^(\-1\b|:\-1:)/', $commentBody)) {
if (preg_match('/^\s*(\-1\b|:\-1:)/', $commentBody)) {
return -1;
}
return 0;
Expand Down
15 changes: 12 additions & 3 deletions tests/PlusPull/GitHub/PullRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@ public function checkCommentsProvider()
'whitelist' => null,
'expected' => false,
),
'weird spacing blocker' => array(
'comments' => array(
new Comment('self', "\n[B]"),
new Comment('userb', '+1'),
new Comment('userc', '+1'),
),
'whitelist' => null,
'expected' => false,
),
'ok' => array(
'comments' => array(
new Comment('usera', '+1'),
new Comment('usera', ' +1'),
new Comment('userb', '+1'),
),
'whitelist' => null,
Expand All @@ -50,7 +59,7 @@ public function checkCommentsProvider()
'comments' => array(
new Comment('usera', '+1'),
new Comment('userb', '+1'),
new Comment('userc', '-1'),
new Comment('userc', ' -1'),
),
'whitelist' => null,
'expected' => false,
Expand Down Expand Up @@ -84,7 +93,7 @@ public function checkCommentsProvider()
'whitelist ko' => array(
'comments' => array(
new Comment('usera', '+1'),
new Comment('userb', '+1'),
new Comment('userb', ':+1:'),
),
'whitelist' => array('usera'),
'expected' => false,
Expand Down

0 comments on commit fb10294

Please sign in to comment.