@@ -42,13 +42,11 @@ async function run() {
42
42
configPath
43
43
) ;
44
44
for ( const [ label , regexs ] of labelTitleRegex . entries ( ) ) {
45
- core . debug ( `[labelTitleRegex] processing ${ label } ` ) ;
46
- for ( const regex of regexs ) {
47
- core . info ( `label: ${ label } , regex: ${ regex } ` ) ;
48
- if ( prTitle != undefined && regex . test ( prTitle ) ) {
49
- core . info ( `in` ) ;
50
- labels . push ( label ) ;
51
- }
45
+ core . debug ( `processing ${ label } ` ) ;
46
+ if ( checkRegexs ( prTitle , regexs ) ) {
47
+ labels . push ( label ) ;
48
+ } else if ( pullRequest . labels . find ( l => l . name === label ) ) {
49
+ labelsToRemove . push ( label ) ;
52
50
}
53
51
}
54
52
@@ -91,10 +89,10 @@ function getPrNumber(): number | undefined {
91
89
return pullRequest . number ;
92
90
}
93
91
94
- function getPrTitle ( ) : string | undefined {
92
+ function getPrTitle ( ) : string {
95
93
const pullRequest = github . context . payload . pull_request ;
96
94
if ( ! pullRequest ) {
97
- return undefined ;
95
+ return '' ;
98
96
}
99
97
100
98
return pullRequest . title ;
@@ -200,11 +198,9 @@ function getLabelTitleRegexMapFromObject(
200
198
for ( const label in configObject [ "title" ] ) {
201
199
const val = configObject [ "title" ] [ label ] ;
202
200
if ( typeof val === "string" ) {
203
- titleRegexs . set ( label , [ new RegExp ( val ) ] ) ;
204
- core . info ( `label: ${ label } , ${ val } , ${ titleRegexs } ` )
201
+ titleRegexs . set ( label , [ new RegExp ( val , 'i' ) ] ) ;
205
202
} else if ( val instanceof Array ) {
206
- core . info ( `label: ${ label } , ${ val } ` )
207
- titleRegexs . set ( label , val . map ( regexStr => new RegExp ( regexStr ) ) ) ;
203
+ titleRegexs . set ( label , val . map ( regexStr => new RegExp ( regexStr , 'i' ) ) ) ;
208
204
} else {
209
205
throw Error (
210
206
`found unexpected type for label ${ label } (should be string or array of regex)`
@@ -245,6 +241,18 @@ function checkGlobs(
245
241
return false ;
246
242
}
247
243
244
+ function checkRegexs (
245
+ prTitle : string ,
246
+ regexs : RegExp [ ]
247
+ ) : boolean {
248
+ for ( const regex of regexs ) {
249
+ if ( regex . test ( prTitle ) ) {
250
+ return true ;
251
+ }
252
+ }
253
+ return false ;
254
+ }
255
+
248
256
function isMatch ( changedFile : string , matchers : IMinimatch [ ] ) : boolean {
249
257
core . debug ( ` matching patterns against file ${ changedFile } ` ) ;
250
258
for ( const matcher of matchers ) {
0 commit comments