Skip to content

Commit 4fff50b

Browse files
committed
bug #142 Make sure we consider case when updating title (Nyholm)
This PR was merged into the master branch. Discussion ---------- Make sure we consider case when updating title Just a small bugfix. To avoid names like: ``` [TwigBundle] [twigbundle] Fixed syntax error in config ``` #SymfonyHackday Commits ------- 3687b67 Make sure we consider case when updating title
2 parents e263c26 + 3687b67 commit 4fff50b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Subscriber/AutoUpdateTitleWithLabelSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function onPullRequest(GitHubEvent $event)
5050
if ('dddddd' === strtolower($label['color'])) {
5151
$validLabels[] = $label['name'];
5252
// Remove label name from title
53-
$prTitle = str_replace('['.$label['name'].']', '', $prTitle);
53+
$prTitle = str_ireplace('['.$label['name'].']', '', $prTitle);
5454

5555
// Remove label aliases from title
5656
foreach ($this->labelExtractor->getAliasesForLabel($label['name']) as $alias) {
57-
$prTitle = str_replace('['.$alias.']', '', $prTitle);
57+
$prTitle = str_ireplace('['.$alias.']', '', $prTitle);
5858
}
5959
}
6060
}

tests/Subscriber/AutoUpdateTitleWithLabelSubscriberTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@ public function testOnPullRequestLabeled()
6565
$this->assertSame('[Console][FrameworkBundle] [bar] Foo', $responseData['new_title']);
6666
}
6767

68+
public function testOnPullRequestLabeledCaseInsensitive()
69+
{
70+
$event = new GitHubEvent([
71+
'action' => 'labeled',
72+
'number' => 1234,
73+
'pull_request' => [
74+
'title' => '[PHPunitbridge] Foo',
75+
'labels' => [
76+
['name' => 'PhpUnitBridge', 'color' => 'dddddd'],
77+
],
78+
],
79+
], $this->repository);
80+
81+
$this->dispatcher->dispatch($event, GitHubEvents::PULL_REQUEST);
82+
$responseData = $event->getResponseData();
83+
84+
$this->assertCount(2, $responseData);
85+
$this->assertSame(1234, $responseData['pull_request']);
86+
$this->assertSame('[PhpUnitBridge] Foo', $responseData['new_title']);
87+
}
88+
6889
public function testOnPullRequestLabeledWithExisting()
6990
{
7091
$event = new GitHubEvent([

0 commit comments

Comments
 (0)