Skip to content

Commit 09fa126

Browse files
committed
bug #130 When a PR is open with "WIP", add status: needs work (Nyholm)
This PR was squashed before being merged into the master branch. Discussion ---------- When a PR is open with "WIP", add status: needs work Follow up from #123 Currently, an PR opened with "WIP:" in the title dont get any status. Commits ------- d006101 fixes faf9bd7 When a PR is open with "WIP", add status: needs work
2 parents 580c0ac + d006101 commit 09fa126

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Subscriber/NeedsReviewNewPRSubscriber.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ public function onPullRequest(GitHubEvent $event)
2929
return;
3030
}
3131

32+
$newStatus = Status::NEEDS_REVIEW;
3233
if (WipParser::matchTitle($data['pull_request']['title'])) {
33-
return;
34+
$newStatus = Status::NEEDS_WORK;
3435
}
3536

3637
$pullRequestNumber = $data['pull_request']['number'];
37-
$newStatus = Status::NEEDS_REVIEW;
38-
3938
$this->statusApi->setIssueStatus($pullRequestNumber, $newStatus, $repository);
4039

4140
$event->setResponseData([

tests/Subscriber/NeedsReviewNewPRSubscriberTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public function testOnPullRequestOpen()
5656

5757
public function testOnPullRequestOpenWIP()
5858
{
59-
$this->statusApi->expects($this->never())
59+
$this->statusApi->expects($this->once())
6060
->method('setIssueStatus')
61-
->with(1234, Status::NEEDS_REVIEW);
61+
->with(1234, Status::NEEDS_WORK);
6262

6363
$event = new GitHubEvent([
6464
'action' => 'opened',
@@ -68,7 +68,9 @@ public function testOnPullRequestOpenWIP()
6868
$this->dispatcher->dispatch($event, GitHubEvents::PULL_REQUEST);
6969

7070
$responseData = $event->getResponseData();
71-
$this->assertEmpty($responseData);
71+
$this->assertCount(2, $responseData);
72+
$this->assertSame(1234, $responseData['pull_request']);
73+
$this->assertSame(Status::NEEDS_WORK, $responseData['status_change']);
7274
}
7375

7476
public function testOnPullRequestNotOpen()

0 commit comments

Comments
 (0)