- introduce new configuration option to define category labels to be exhaustive

- require all labels of a category to be present in the matching PR
- update to typescript 4.4.x
- recompile dist
This commit is contained in:
Mike Penz
2021-08-27 11:41:20 +02:00
parent 354828ea24
commit cfac2f37a1
11 changed files with 203 additions and 125 deletions
+24 -8
View File
@@ -103,14 +103,26 @@ export function buildChangelog(
let matched = false
for (const [category, pullRequests] of categorized) {
if (
haveCommonElements(
category.labels.map(lbl => lbl.toLocaleLowerCase()),
pr.labels
)
) {
pullRequests.push(body)
matched = true
if (category.exhaustive === true) {
if (
haveEveryElements(
category.labels.map(lbl => lbl.toLocaleLowerCase()),
pr.labels
)
) {
pullRequests.push(body)
matched = true
}
} else {
if (
haveCommonElements(
category.labels.map(lbl => lbl.toLocaleLowerCase()),
pr.labels
)
) {
pullRequests.push(body)
matched = true
}
}
}
@@ -213,6 +225,10 @@ function haveCommonElements(arr1: string[], arr2: Set<string>): Boolean {
return arr1.some(item => arr2.has(item))
}
function haveEveryElements(arr1: string[], arr2: Set<string>): Boolean {
return arr1.every(item => arr2.has(item))
}
function fillTemplate(pr: PullRequestInfo, template: string): string {
let transformed = template
transformed = transformed.replace(/\${{NUMBER}}/g, pr.number.toString())