Skip to content

Commit 2116d71

Browse files
author
Naka Masato
committed
fix
1 parent 8fc40c7 commit 2116d71

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

dist/index.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -14558,13 +14558,12 @@ function run() {
1455814558
// add label based on title
1455914559
const labelTitleRegex = yield getLabelTitleRegex(client, configPath);
1456014560
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);
1456814567
}
1456914568
}
1457014569
// add label based on changed files
@@ -14603,7 +14602,7 @@ function getPrNumber() {
1460314602
function getPrTitle() {
1460414603
const pullRequest = github.context.payload.pull_request;
1460514604
if (!pullRequest) {
14606-
return undefined;
14605+
return '';
1460714606
}
1460814607
return pullRequest.title;
1460914608
}
@@ -14679,12 +14678,10 @@ function getLabelTitleRegexMapFromObject(configObject) {
1467914678
for (const label in configObject["title"]) {
1468014679
const val = configObject["title"][label];
1468114680
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')]);
1468414682
}
1468514683
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')));
1468814685
}
1468914686
else {
1469014687
throw Error(`found unexpected type for label ${label} (should be string or array of regex)`);
@@ -14715,6 +14712,14 @@ function checkGlobs(changedFiles, globs) {
1471514712
}
1471614713
return false;
1471714714
}
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+
}
1471814723
function isMatch(changedFile, matchers) {
1471914724
core.debug(` matching patterns against file ${changedFile}`);
1472014725
for (const matcher of matchers) {

0 commit comments

Comments
 (0)