@@ -14558,13 +14558,12 @@ function run() {
14558
14558
// add label based on title
14559
14559
const labelTitleRegex = yield getLabelTitleRegex(client, configPath);
14560
14560
for (const [label, regexs] of labelTitleRegex.entries()) {
14561
- core.debug(`[labelTitleRegex] processing ${label}`);
14562
- for (const regex of regexs) {
14563
- core.info(`label: ${label}, regex: ${regex}`);
14564
- if (prTitle != undefined && regex.test(prTitle)) {
14565
- core.info(`in`);
14566
- labels.push(label);
14567
- }
14561
+ core.debug(`processing ${label}`);
14562
+ if (checkRegexs(prTitle, regexs)) {
14563
+ labels.push(label);
14564
+ }
14565
+ else if (pullRequest.labels.find(l => l.name === label)) {
14566
+ labelsToRemove.push(label);
14568
14567
}
14569
14568
}
14570
14569
// add label based on changed files
@@ -14603,7 +14602,7 @@ function getPrNumber() {
14603
14602
function getPrTitle() {
14604
14603
const pullRequest = github.context.payload.pull_request;
14605
14604
if (!pullRequest) {
14606
- return undefined ;
14605
+ return '' ;
14607
14606
}
14608
14607
return pullRequest.title;
14609
14608
}
@@ -14679,12 +14678,10 @@ function getLabelTitleRegexMapFromObject(configObject) {
14679
14678
for (const label in configObject["title"]) {
14680
14679
const val = configObject["title"][label];
14681
14680
if (typeof val === "string") {
14682
- titleRegexs.set(label, [new RegExp(val)]);
14683
- core.info(`label: ${label}, ${val}, ${titleRegexs}`);
14681
+ titleRegexs.set(label, [new RegExp(val, 'i')]);
14684
14682
}
14685
14683
else if (val instanceof Array) {
14686
- core.info(`label: ${label}, ${val}`);
14687
- titleRegexs.set(label, val.map(regexStr => new RegExp(regexStr)));
14684
+ titleRegexs.set(label, val.map(regexStr => new RegExp(regexStr, 'i')));
14688
14685
}
14689
14686
else {
14690
14687
throw Error(`found unexpected type for label ${label} (should be string or array of regex)`);
@@ -14715,6 +14712,14 @@ function checkGlobs(changedFiles, globs) {
14715
14712
}
14716
14713
return false;
14717
14714
}
14715
+ function checkRegexs(prTitle, regexs) {
14716
+ for (const regex of regexs) {
14717
+ if (regex.test(prTitle)) {
14718
+ return true;
14719
+ }
14720
+ }
14721
+ return false;
14722
+ }
14718
14723
function isMatch(changedFile, matchers) {
14719
14724
core.debug(` matching patterns against file ${changedFile}`);
14720
14725
for (const matcher of matchers) {
0 commit comments