From 45f8fb9f0505719b41e5bcb22475b413b50bcab2 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 17 Aug 2023 14:36:48 -0400 Subject: [PATCH] chore(NODE-5544): fix duplicate PR highlights (#3816) --- .github/scripts/highlights.mjs | 5 ++++- .github/scripts/pr_list.mjs | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/scripts/highlights.mjs b/.github/scripts/highlights.mjs index 49cea1bff1..6df213dced 100644 --- a/.github/scripts/highlights.mjs +++ b/.github/scripts/highlights.mjs @@ -70,7 +70,10 @@ async function pullRequestHighlights(prs) { if (!highlights.length) return ''; highlights.unshift('## Release Notes\n\n'); - return highlights.join('\n\n'); + + const highlight = highlights.join('\n\n'); + console.log(`Total highlight is ${highlight.length} characters long`); + return highlight; } console.log('List of PRs to collect highlights from:', prs); diff --git a/.github/scripts/pr_list.mjs b/.github/scripts/pr_list.mjs index 68639e2dea..6b31cd25c1 100644 --- a/.github/scripts/pr_list.mjs +++ b/.github/scripts/pr_list.mjs @@ -13,10 +13,14 @@ const historyFilePath = path.join(__dirname, '..', '..', 'HISTORY.md'); */ function parsePRList(history) { const prRegexp = /node-mongodb-native\/issues\/(?\d+)\)/iu; - return history - .split('\n') - .map(line => prRegexp.exec(line)?.groups?.prNum ?? '') - .filter(prNum => prNum !== ''); + return Array.from( + new Set( + history + .split('\n') + .map(line => prRegexp.exec(line)?.groups?.prNum ?? '') + .filter(prNum => prNum !== '') + ) + ); } const historyContents = await fs.readFile(historyFilePath, { encoding: 'utf8' });