- add helper methods for tsts
- add new ability to recursively build changelog - add feature to consume PRs if they were matched to a category - keep header if children have entry
This commit is contained in:
+25
-13
@@ -2764,26 +2764,26 @@ exports.buildChangelog = buildChangelog;
|
||||
function recursiveCategorizePr(category, pr, body) {
|
||||
let matched = false;
|
||||
let consumed = false;
|
||||
if (category.categories) {
|
||||
const matchesParent = categorizePr(category, pr);
|
||||
// only do children if parent also matches
|
||||
if (category.categories && matchesParent) {
|
||||
for (const childCategory of category.categories) {
|
||||
const pullRequests = childCategory.entries || [];
|
||||
matched = categorizePr(childCategory, pr);
|
||||
if (matched) {
|
||||
pullRequests.push(body); // if matched add the PR to the list
|
||||
}
|
||||
if (childCategory.consume) {
|
||||
consumed = true;
|
||||
continue;
|
||||
}
|
||||
const [childMatched, childConsumed] = recursiveCategorizePr(childCategory, pr, body);
|
||||
matched = matched || childMatched; // at least one time it matched
|
||||
consumed = childConsumed;
|
||||
}
|
||||
}
|
||||
if (!consumed) {
|
||||
// if consumed we don't handle it anymore, as it was matched in a child, don't handle anymore
|
||||
if (!consumed && !matched) {
|
||||
const pullRequests = category.entries || [];
|
||||
matched = categorizePr(category, pr);
|
||||
matched = matchesParent;
|
||||
if (matched) {
|
||||
pullRequests.push(body); // if matched add the PR to the list
|
||||
}
|
||||
}
|
||||
if (matched && category.consume) {
|
||||
consumed = true;
|
||||
}
|
||||
return [matched, consumed];
|
||||
}
|
||||
function categorizePr(category, pr) {
|
||||
@@ -2830,7 +2830,7 @@ function categorizePr(category, pr) {
|
||||
return matched;
|
||||
}
|
||||
function attachCategoryChangelog(changelog, category, pullRequests) {
|
||||
if (pullRequests.length > 0) {
|
||||
if (pullRequests.length > 0 || hasChildWithEntries(category)) {
|
||||
if (category.title) {
|
||||
changelog = `${changelog + category.title}\n\n`;
|
||||
}
|
||||
@@ -3065,6 +3065,18 @@ function flatten(categories) {
|
||||
return r.concat([i]).concat(flatten(i.categories));
|
||||
}, []);
|
||||
}
|
||||
function hasChildWithEntries(category) {
|
||||
var _a;
|
||||
const categories = category.categories;
|
||||
if (!categories || categories.length === 0) {
|
||||
return (((_a = category.entries) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0;
|
||||
}
|
||||
let hasEntries = false;
|
||||
for (const cat of categories) {
|
||||
hasEntries = hasEntries || hasChildWithEntries(cat);
|
||||
}
|
||||
return hasEntries;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user