@@ -71,9 +71,9 @@ public function handlePullRequestCreatedEvent($prNumber, $prTitle, $prBody)
71
71
$ newStatus = Status::NEEDS_REVIEW ;
72
72
$ prLabels [] = $ newStatus ;
73
73
74
- // the PR title usually indicates the affected component
75
- if ( preg_match ( ' /^\[(?P<component>.*)\] .*/$ ' , $ prTitle , $ matches ) ) {
76
- $ prLabels [] = $ matches [ ' component ' ] ;
74
+ // the PR title usually contains one or more labels
75
+ foreach ( $ this -> extractLabels ( $ prTitle ) as $ label ) {
76
+ $ prLabels [] = $ label ;
77
77
}
78
78
79
79
// the PR body usually indicates if this is a Bug, Feature, BC Break or Deprecation
@@ -123,4 +123,40 @@ public function handleLabelAddedEvent($issueNumber, $label)
123
123
124
124
return $ newStatus ;
125
125
}
126
+
127
+ private function extractLabels ($ prTitle )
128
+ {
129
+ $ labels = array ();
130
+
131
+ // e.g. "[PropertyAccess] [RFC] [WIP] Allow custom methods on property accesses"
132
+ if (preg_match_all ('/\[(?P<tags>.+)\]/U ' , $ prTitle , $ matches )) {
133
+ foreach ($ matches ['tags ' ] as $ tag ) {
134
+ if (in_array ($ tag , $ this ->getValidTags ())) {
135
+ $ labels [] = $ tag ;
136
+ }
137
+ }
138
+ }
139
+
140
+ return $ labels ;
141
+ }
142
+
143
+ /**
144
+ * TODO: get valid tags from the repository via GitHub API
145
+ */
146
+ private function getValidTags ()
147
+ {
148
+ return array (
149
+ 'Asset ' , 'BC Break ' , 'BrowserKit ' , 'Bug ' , 'Cache ' , 'ClassLoader ' ,
150
+ 'Config ' , 'Console ' , 'Critical ' , 'CssSelector ' , 'Debug ' , 'DebugBundle ' ,
151
+ 'DependencyInjection ' , 'Deprecation ' , 'Doctrine ' , 'DoctrineBridge ' ,
152
+ 'DomCrawler ' , 'Drupal related ' , 'DX ' , 'Easy Pick ' , 'Enhancement ' ,
153
+ 'EventDispatcher ' , 'ExpressionLanguage ' , 'Feature ' , 'Filesystem ' ,
154
+ 'Finder ' , 'Form ' , 'FrameworkBundle ' , 'HttpFoundation ' , 'HttpKernel ' ,
155
+ 'Intl ' , 'Ldap ' , 'Locale ' , 'MonologBridge ' , 'OptionsResolver ' ,
156
+ 'PhpUnitBridge ' , 'Process ' , 'PropertyAccess ' , 'PropertyInfo ' , 'Ready ' ,
157
+ 'RFC ' , 'Routing ' , 'Security ' , 'SecurityBundle ' , 'Serializer ' ,
158
+ 'Stopwatch ' , 'Templating ' , 'Translator ' , 'TwigBridge ' , 'TwigBundle ' ,
159
+ 'Unconfirmed ' , 'Validator ' , 'VarDumper ' , 'WebProfilerBundle ' , 'Yaml ' ,
160
+ );
161
+ }
126
162
}
0 commit comments