fix(changelog): deduplicate merged PR entries in preview#690
Merged
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛Changelog
Other
🤖 This preview updates automatically when you update the PR. |
fb04caa to
0ce18e1
Compare
BYK
commented
Dec 30, 2025
When viewing the changelog preview for a PR that is already merged (e.g., after editing its title/description), the PR would appear twice: once from git history and once from the freshly-fetched PR info. This adds deduplication at two levels: 1. In fetchRawCommitInfo: Deduplicates commits with the same PR number from git history. This handles rebase-merge workflows where multiple commits are associated with the same PR. 2. In generateChangelogWithHighlight: Filters the current PR from git history before prepending the fresh highlighted version. The deduplication keeps the first (newest) occurrence since git log returns commits newest-first, ensuring we use the most up-to-date data.
0ce18e1 to
68836bc
Compare
MathurAditya724
approved these changes
Dec 30, 2025
This was referenced Dec 31, 2025
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: