Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Naka Masato committed Oct 22, 2020
1 parent 8fc40c7 commit 2116d71
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions dist/index.js
Expand Up @@ -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
Expand Down Expand Up @@ -14603,7 +14602,7 @@ function getPrNumber() {
function getPrTitle() {
const pullRequest = github.context.payload.pull_request;
if (!pullRequest) {
return undefined;
return '';
}
return pullRequest.title;
}
Expand Down Expand Up @@ -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)`);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2116d71

Please sign in to comment.