- enhance handling for exhaustive matching

- exhaustive will apply on rules and labels alike
- simplify code
- introduce new testcases to check the new behavior
This commit is contained in:
Mike Penz
2023-01-06 09:13:30 +00:00
committed by GitHub
parent f2b16254cf
commit 50dd476bd1
6 changed files with 170 additions and 238 deletions
Generated Vendored
+20 -18
View File
@@ -1804,33 +1804,35 @@ function buildChangelog(diffInfo, prs, options) {
continue; // one of the exclude labels matched, skip the PR for this category
}
}
if (category.labels !== undefined) {
if (category.exhaustive === true) {
if ((0, utils_1.haveEveryElements)(category.labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels)) {
pullRequests.push(body);
matched = true;
}
// in case we have exhaustive matching enabled, and have labels and/or rules
// validate for an exhaustive match (e.g. every provided rule applies)
if (category.exhaustive === true && (category.labels !== undefined || category.rules !== undefined)) {
if (category.labels !== undefined) {
matched = (0, utils_1.haveEveryElements)(category.labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels);
}
else {
if ((0, utils_1.haveCommonElements)(category.labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels)) {
pullRequests.push(body);
matched = true;
}
if (matched && category.rules !== undefined) {
matched = (0, regexUtils_1.matchesRules)(category.rules, pr, true);
}
}
if (category.rules !== undefined) {
if ((0, regexUtils_1.matchesRules)(category.rules, pr, category.exhaustive === true)) {
pullRequests.push(body);
matched = true;
else {
// if not exhaustive, do individual matches
if (category.labels !== undefined) {
// check if either any of the labels applies
matched = (0, utils_1.haveCommonElements)(category.labels.map(lbl => lbl.toLocaleLowerCase('en')), pr.labels);
}
if (!matched && category.rules !== undefined) {
// if no label did apply, check if any rule applies
matched = (0, regexUtils_1.matchesRules)(category.rules, pr, false);
}
}
if (matched) {
pullRequests.push(body); // if matched add the PR to the list
}
}
if (!matched) {
// we allow to have pull requests included in an "uncategorized" category
for (const [category, pullRequests] of categorized) {
if ((category.labels === undefined || category.labels.length === 0) &&
category.rules === undefined &&
category.exclude_labels === undefined) {
if ((category.labels === undefined || category.labels.length === 0) && category.rules === undefined) {
pullRequests.push(body);
break;
}
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long