Skip to content

Commit 1fcc0a7

Browse files
committed
bug #148 If there is a comment on a closed issue, then dont remove "stalled" label (Nyholm)
This PR was merged into the master branch. Discussion ---------- If there is a comment on a closed issue, then dont remove "stalled" label This is just nice to have Example: symfony/symfony#32597 Commits ------- ffb058b If there is a comment on a closed issue, then dont remove "stalled" label
2 parents db59927 + ffb058b commit 1fcc0a7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/Subscriber/RemoveStalledLabelOnCommentSubscriber.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public function onIssueComment(GitHubEvent $event)
3434
return;
3535
}
3636

37+
// If not open, then do nothing
38+
if ('open' !== $data['issue']['state']) {
39+
return;
40+
}
41+
3742
$removed = false;
3843
$issueNumber = $data['issue']['number'];
3944
foreach ($data['issue']['labels'] as $label) {

tests/Subscriber/RemoveStalledLabelOnCommentSubscriberTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function setUp()
3535
public function testOnComment()
3636
{
3737
$event = new GitHubEvent([
38-
'issue' => ['number' => 1234, 'labels' => []], 'comment' => ['user' => ['login' => 'nyholm']],
38+
'issue' => ['number' => 1234, 'state' => 'open', 'labels' => []], 'comment' => ['user' => ['login' => 'nyholm']],
3939
], $this->repository);
4040

4141
$this->dispatcher->dispatch($event, GitHubEvents::ISSUE_COMMENT);
@@ -47,7 +47,7 @@ public function testOnComment()
4747
public function testOnCommentOnStale()
4848
{
4949
$event = new GitHubEvent([
50-
'issue' => ['number' => 1234, 'labels' => [['name' => 'Foo'], ['name' => 'Stalled']]], 'comment' => ['user' => ['login' => 'nyholm']],
50+
'issue' => ['number' => 1234, 'state' => 'open', 'labels' => [['name' => 'Foo'], ['name' => 'Stalled']]], 'comment' => ['user' => ['login' => 'nyholm']],
5151
], $this->repository);
5252

5353
$this->dispatcher->dispatch($event, GitHubEvents::ISSUE_COMMENT);
@@ -61,7 +61,19 @@ public function testOnCommentOnStale()
6161
public function testOnBotCommentOnStale()
6262
{
6363
$event = new GitHubEvent([
64-
'issue' => ['number' => 1234, 'labels' => [['name' => 'Foo'], ['name' => 'Stalled']]], 'comment' => ['user' => ['login' => 'carsonbot']],
64+
'issue' => ['number' => 1234, 'state' => 'open', 'labels' => [['name' => 'Foo'], ['name' => 'Stalled']]], 'comment' => ['user' => ['login' => 'carsonbot']],
65+
], $this->repository);
66+
67+
$this->dispatcher->dispatch($event, GitHubEvents::ISSUE_COMMENT);
68+
69+
$responseData = $event->getResponseData();
70+
$this->assertEmpty($responseData);
71+
}
72+
73+
public function testCommentOnClosed()
74+
{
75+
$event = new GitHubEvent([
76+
'issue' => ['number' => 1234, 'state' => 'closed', 'labels' => [['name' => 'Foo'], ['name' => 'Stalled']]], 'comment' => ['user' => ['login' => 'nyholm']],
6577
], $this->repository);
6678

6779
$this->dispatcher->dispatch($event, GitHubEvents::ISSUE_COMMENT);

0 commit comments

Comments
 (0)