Skip to content

Commit 8359dc7

Browse files
committed
Added support for common label mispellings and aliases
1 parent 3e3b8ee commit 8359dc7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/AppBundle/Subscriber/AutoLabelPRFromContentSubscriber.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ private function extractLabels($prTitle)
7878
);
7979

8080
foreach ($matches['labels'] as $label) {
81+
$label = $this->fixLabelName($label);
82+
8183
// check case-insensitively, but the apply the correctly-cased label
8284
if (isset($validLabels[strtolower($label)])) {
8385
$labels[] = $validLabels[strtolower($label)];
@@ -109,6 +111,27 @@ private function getValidLabels()
109111
);
110112
}
111113

114+
/**
115+
* It fixes common misspellings and aliases commonly used for label names
116+
* (e.g. DI -> DependencyInjection).
117+
*/
118+
private function fixLabelName($label)
119+
{
120+
$labelAliases = array(
121+
'di' => 'DependencyInjection',
122+
'bridge\twig' => 'TwigBridge',
123+
'router' => 'Routing',
124+
'translation' => 'Translator',
125+
'twig bridge' => 'TwigBridge',
126+
);
127+
128+
if (in_array(strtolower($label), $labelAliases)) {
129+
return $labelAliases[strtolower($label)];
130+
}
131+
132+
return $label;
133+
}
134+
112135
public static function getSubscribedEvents()
113136
{
114137
return array(

0 commit comments

Comments
 (0)