- do not drop PRs if they did not result in an extracted identifier during deduplication

- FIX https://github.com/mikepenz/release-changelog-builder-action/issues/483
- adjust log to `info` if `ID` extraction fails for PR
- merge together PRs post deduplication (with unmatched array)
- ensure proper sorting of PRs post deduplication
This commit is contained in:
Mike Penz
2021-09-14 13:38:49 +02:00
parent a035e38233
commit 99d5df5b47
5 changed files with 77 additions and 64 deletions
+6 -3
View File
@@ -26,22 +26,25 @@ export function buildChangelog(
core.info(`️ Remove duplicated pull requests using \`duplicate_filter\``)
const deduplicatedMap = new Map<string, PullRequestInfo>()
const unmatched: PullRequestInfo[] = []
for (const pr of prs) {
const extracted = extractValues(pr, extractor, 'dupliate_filter')
if (extracted !== null && extracted.length > 0) {
deduplicatedMap.set(extracted[0], pr)
} else {
core.debug(
` PR (${pr.number}) did not resolve a ID using the \`duplicate_filter\``
core.info(
` PR (${pr.number}) did not resolve an ID using the \`duplicate_filter\``
)
unmatched.push(pr)
}
}
const deduplicatedPRs = Array.from(deduplicatedMap.values())
deduplicatedPRs.push(...unmatched) // add all unmatched PRs to map
const removedElements = prs.length - deduplicatedPRs.length
core.info(
`️ Removed ${removedElements} pull requests during deduplication`
)
prs = deduplicatedPRs
prs = sortPullRequests(deduplicatedPRs, sortAsc) // resort deduplicatedPRs
} else {
core.warning(`⚠️ Configured \`duplicate_filter\` invalid.`)
}