add possibility to configure if rules are and/or independently from labels

This commit is contained in:
Federico M. Facca
2023-05-03 17:50:51 +02:00
parent fa8d0100dc
commit 1794edb8f3
4 changed files with 17 additions and 8 deletions
+2 -1
View File
@@ -23,7 +23,8 @@ export interface Category {
labels?: string[] // labels to associate PRs to this category
exclude_labels?: string[] // if an exclude label is detected, the PR will be excluded from this category
rules?: Rule[] // rules to associate PRs to this category
exhaustive?: boolean // requires all labels AND/OR rules to be present in the PR
exhaustive?: boolean // requires all labels to be present in the PR
exclusive_rules?: boolean // requires all rules to be present in the PR (if not set, defaults to exhaustive value)
empty_content?: string // if the category has no matching PRs, this content will be used. If not set, the category will be skipped in the changelog.
}
+10 -2
View File
@@ -133,8 +133,12 @@ export function buildChangelog(diffInfo: DiffInfo, prs: PullRequestInfo[], optio
pr.labels
)
}
let exclusive_rules = true
if (category.exclusive_rules !== undefined) {
exclusive_rules = category.exclusive_rules
}
if (matched && category.rules !== undefined) {
matched = matchesRules(category.rules, pr, true)
matched = matchesRules(category.rules, pr, exclusive_rules)
}
} else {
// if not exhaustive, do individual matches
@@ -145,9 +149,13 @@ export function buildChangelog(diffInfo: DiffInfo, prs: PullRequestInfo[], optio
pr.labels
)
}
let exclusive_rules = false
if (category.exclusive_rules !== undefined) {
exclusive_rules = category.exclusive_rules
}
if (!matched && category.rules !== undefined) {
// if no label did apply, check if any rule applies
matched = matchesRules(category.rules, pr, false)
matched = matchesRules(category.rules, pr, exclusive_rules)
}
}
if (matched) {