diff --git a/dist/index.js b/dist/index.js index c3b64461d..e32197039 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14558,13 +14558,12 @@ function run() { // add label based on title const labelTitleRegex = yield getLabelTitleRegex(client, configPath); for (const [label, regexs] of labelTitleRegex.entries()) { - core.debug(`[labelTitleRegex] processing ${label}`); - for (const regex of regexs) { - core.info(`label: ${label}, regex: ${regex}`); - if (prTitle != undefined && regex.test(prTitle)) { - core.info(`in`); - labels.push(label); - } + core.debug(`processing ${label}`); + if (checkRegexs(prTitle, regexs)) { + labels.push(label); + } + else if (pullRequest.labels.find(l => l.name === label)) { + labelsToRemove.push(label); } } // add label based on changed files @@ -14603,7 +14602,7 @@ function getPrNumber() { function getPrTitle() { const pullRequest = github.context.payload.pull_request; if (!pullRequest) { - return undefined; + return ''; } return pullRequest.title; } @@ -14679,12 +14678,10 @@ function getLabelTitleRegexMapFromObject(configObject) { for (const label in configObject["title"]) { const val = configObject["title"][label]; if (typeof val === "string") { - titleRegexs.set(label, [new RegExp(val)]); - core.info(`label: ${label}, ${val}, ${titleRegexs}`); + titleRegexs.set(label, [new RegExp(val, 'i')]); } else if (val instanceof Array) { - core.info(`label: ${label}, ${val}`); - titleRegexs.set(label, val.map(regexStr => new RegExp(regexStr))); + titleRegexs.set(label, val.map(regexStr => new RegExp(regexStr, 'i'))); } else { throw Error(`found unexpected type for label ${label} (should be string or array of regex)`); @@ -14715,6 +14712,14 @@ function checkGlobs(changedFiles, globs) { } return false; } +function checkRegexs(prTitle, regexs) { + for (const regex of regexs) { + if (regex.test(prTitle)) { + return true; + } + } + return false; +} function isMatch(changedFile, matchers) { core.debug(` matching patterns against file ${changedFile}`); for (const matcher of matchers) {