Skip to content

Commit 2e7ba8e

Browse files
committed
Allowing for the [Label] PR title things to be case insensitive
1 parent f11462d commit 2e7ba8e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/AppBundle/Subscriber/AutoLabelPRFromContentSubscriber.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,18 @@ private function extractLabels($prTitle)
6969

7070
// e.g. "[PropertyAccess] [RFC] [WIP] Allow custom methods on property accesses"
7171
if (preg_match_all('/\[(?P<labels>.+)\]/U', $prTitle, $matches)) {
72+
// creates a key=>val array, but the key is lowercased
73+
$validLabels = array_combine(
74+
array_map(function($s) {
75+
return strtolower($s);
76+
}, $this->getValidLabels()),
77+
$this->getValidLabels()
78+
);
79+
7280
foreach ($matches['labels'] as $label) {
73-
if (in_array($label, $this->getValidLabels())) {
74-
$labels[] = $label;
81+
// check case-insensitively, but the apply the correctly-cased label
82+
if (isset($validLabels[strtolower($label)])) {
83+
$labels[] = $validLabels[strtolower($label)];
7584
}
7685
}
7786
}

src/AppBundle/Tests/Subscriber/AutoLabelPRFromContentSubscriberTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function getPRTests()
143143
];
144144

145145
$tests[] = [
146-
'[Asset][BC Break][Fake] Extracting from title [Bug]',
146+
'[Asset][bc Break][Fake] Extracting from title [Bug]',
147147
<<<EOF
148148
EOF
149149
,

0 commit comments

Comments
 (0)