fix(changelog): deduplicate merged PR entries in preview #690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When viewing the changelog preview for a PR that is already merged (e.g., after editing its title/description), the PR appears twice in the changelog:
fetchRawCommitInfo)highlight: true)Additionally, in repositories using rebase-merge workflows, multiple commits from a single PR can each be associated with the same PR number via GitHub's
associatedPullRequestsAPI, causing duplicate changelog entries.Fixes #648
Solution
Added deduplication at two levels:
fetchRawCommitInfo: Deduplicates commits with the same PR number from git history using aSet. This handles rebase-merge workflows where multiple commits are associated with the same PR. Keeps the first (newest) occurrence since git log returns commits newest-first.generateChangelogWithHighlight: Filters the current PR from git history before prepending the fresh highlighted version, ensuring we use up-to-date data (e.g., if the PR title was edited after merge).Changes
src/utils/changelog.ts: Added deduplication infetchRawCommitInfoand updated comments ingenerateChangelogWithHighlightsrc/utils/__tests__/changelog-generate.test.ts: Added 3 new tests: