Merge pull request #486 from mikepenz/feature/enhance_deduplication
Enhance `deduplication` behaviour
This commit is contained in:
@@ -311,7 +311,7 @@ it('Deduplicate duplicated PRs', async () => {
|
||||
})
|
||||
|
||||
expect(resultChangelog).toStrictEqual(
|
||||
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n\n`
|
||||
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
+12
-2
@@ -1142,19 +1142,22 @@ function buildChangelog(prs, options) {
|
||||
if (extractor != null) {
|
||||
core.info(`ℹ️ Remove duplicated pull requests using \`duplicate_filter\``);
|
||||
const deduplicatedMap = new Map();
|
||||
const unmatched = [];
|
||||
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 = (0, pullRequests_1.sortPullRequests)(deduplicatedPRs, sortAsc); // resort deduplicatedPRs
|
||||
}
|
||||
else {
|
||||
core.warning(`⚠️ Configured \`duplicate_filter\` invalid.`);
|
||||
@@ -1445,8 +1448,15 @@ function resolveConfiguration(githubWorkspacePath, configurationFile) {
|
||||
const providedConfiguration = readConfiguration(configurationPath);
|
||||
if (providedConfiguration) {
|
||||
configuration = providedConfiguration;
|
||||
core.info(`ℹ️ Configuration successfully loaded.`);
|
||||
if (core.isDebug()) {
|
||||
core.debug(`configuration = ${JSON.stringify(configuration)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.info(`ℹ️ Configuration not provided. Using Defaults.`);
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
exports.resolveConfiguration = resolveConfiguration;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+55
-55
@@ -21,13 +21,13 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.9.1",
|
||||
"@typescript-eslint/parser": "^4.31.0",
|
||||
"@vercel/ncc": "^0.31.0",
|
||||
"@typescript-eslint/parser": "^4.31.1",
|
||||
"@vercel/ncc": "^0.31.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-github": "^4.3.0",
|
||||
"eslint-plugin-jest": "^24.4.0",
|
||||
"jest": "^27.2.0",
|
||||
"jest-circus": "^27.0.6",
|
||||
"jest-circus": "^27.2.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.4.0",
|
||||
"ts-jest": "^27.0.5",
|
||||
@@ -1550,14 +1550,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.0.tgz",
|
||||
"integrity": "sha512-oWbzvPh5amMuTmKaf1wp0ySxPt2ZXHnFQBN2Szu1O//7LmOvgaKTCIDNLK2NvzpmVd5A2M/1j/rujBqO37hj3w==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz",
|
||||
"integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "4.31.0",
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/typescript-estree": "4.31.0",
|
||||
"@typescript-eslint/scope-manager": "4.31.1",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/typescript-estree": "4.31.1",
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1577,13 +1577,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.0.tgz",
|
||||
"integrity": "sha512-LJ+xtl34W76JMRLjbaQorhR0hfRAlp3Lscdiz9NeI/8i+q0hdBZ7BsiYieLoYWqy+AnRigaD3hUwPFugSzdocg==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/visitor-keys": "4.31.0"
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
@@ -1594,9 +1594,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.0.tgz",
|
||||
"integrity": "sha512-9XR5q9mk7DCXgXLS7REIVs+BaAswfdHhx91XqlJklmqWpTALGjygWVIb/UnLh4NWhfwhR5wNe1yTyCInxVhLqQ==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
@@ -1607,13 +1607,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.0.tgz",
|
||||
"integrity": "sha512-QHl2014t3ptg+xpmOSSPn5hm4mY8D4s97ftzyk9BZ8RxYQ3j73XcwuijnJ9cMa6DO4aLXeo8XS3z1omT9LA/Eg==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz",
|
||||
"integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/visitor-keys": "4.31.0",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1",
|
||||
"debug": "^4.3.1",
|
||||
"globby": "^11.0.3",
|
||||
"is-glob": "^4.0.1",
|
||||
@@ -1634,12 +1634,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.0.tgz",
|
||||
"integrity": "sha512-HUcRp2a9I+P21+O21yu3ezv3GEPGjyGiXoEUQwZXjR8UxRApGeLyWH4ZIIUSalE28aG4YsV6GjtaAVB3QKOu0w==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1725,9 +1725,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vercel/ncc": {
|
||||
"version": "0.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.0.tgz",
|
||||
"integrity": "sha512-vpioWEFk00Sk5CgJj39LFAjqXcM0PLcaSqaEDeZZUKfHEKYmHL5tOns7Xd21/o4SKzRi+XE0qhEv9wWwkfmNaA==",
|
||||
"version": "0.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz",
|
||||
"integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"ncc": "dist/ncc/cli.js"
|
||||
@@ -8245,41 +8245,41 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.0.tgz",
|
||||
"integrity": "sha512-oWbzvPh5amMuTmKaf1wp0ySxPt2ZXHnFQBN2Szu1O//7LmOvgaKTCIDNLK2NvzpmVd5A2M/1j/rujBqO37hj3w==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz",
|
||||
"integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "4.31.0",
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/typescript-estree": "4.31.0",
|
||||
"@typescript-eslint/scope-manager": "4.31.1",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/typescript-estree": "4.31.1",
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.0.tgz",
|
||||
"integrity": "sha512-LJ+xtl34W76JMRLjbaQorhR0hfRAlp3Lscdiz9NeI/8i+q0hdBZ7BsiYieLoYWqy+AnRigaD3hUwPFugSzdocg==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/visitor-keys": "4.31.0"
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.0.tgz",
|
||||
"integrity": "sha512-9XR5q9mk7DCXgXLS7REIVs+BaAswfdHhx91XqlJklmqWpTALGjygWVIb/UnLh4NWhfwhR5wNe1yTyCInxVhLqQ==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.0.tgz",
|
||||
"integrity": "sha512-QHl2014t3ptg+xpmOSSPn5hm4mY8D4s97ftzyk9BZ8RxYQ3j73XcwuijnJ9cMa6DO4aLXeo8XS3z1omT9LA/Eg==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz",
|
||||
"integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/visitor-keys": "4.31.0",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1",
|
||||
"debug": "^4.3.1",
|
||||
"globby": "^11.0.3",
|
||||
"is-glob": "^4.0.1",
|
||||
@@ -8288,12 +8288,12 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.0.tgz",
|
||||
"integrity": "sha512-HUcRp2a9I+P21+O21yu3ezv3GEPGjyGiXoEUQwZXjR8UxRApGeLyWH4ZIIUSalE28aG4YsV6GjtaAVB3QKOu0w==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.0",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -8341,9 +8341,9 @@
|
||||
}
|
||||
},
|
||||
"@vercel/ncc": {
|
||||
"version": "0.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.0.tgz",
|
||||
"integrity": "sha512-vpioWEFk00Sk5CgJj39LFAjqXcM0PLcaSqaEDeZZUKfHEKYmHL5tOns7Xd21/o4SKzRi+XE0qhEv9wWwkfmNaA==",
|
||||
"version": "0.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz",
|
||||
"integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==",
|
||||
"dev": true
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
|
||||
+3
-3
@@ -44,13 +44,13 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.9.1",
|
||||
"@typescript-eslint/parser": "^4.31.0",
|
||||
"@vercel/ncc": "^0.31.0",
|
||||
"@typescript-eslint/parser": "^4.31.1",
|
||||
"@vercel/ncc": "^0.31.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-github": "^4.3.0",
|
||||
"eslint-plugin-jest": "^24.4.0",
|
||||
"jest": "^27.2.0",
|
||||
"jest-circus": "^27.0.6",
|
||||
"jest-circus": "^27.2.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.4.0",
|
||||
"ts-jest": "^27.0.5",
|
||||
|
||||
+6
-3
@@ -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.`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user