Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Dec 30, 2025

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:

  • Once from git history (via fetchRawCommitInfo)
  • Once from the current PR fetch (with 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 associatedPullRequests API, causing duplicate changelog entries.

Fixes #648

Solution

Added deduplication at two levels:

  1. fetchRawCommitInfo: Deduplicates commits with the same PR number from git history using a Set. 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.

  2. 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 in fetchRawCommitInfo and updated comments in generateChangelogWithHighlight
  • src/utils/__tests__/changelog-generate.test.ts: Added 3 new tests:
    • Merged PR deduplication scenario
    • Rebase-merge workflow with multiple commits per PR
    • Commits without PR association are preserved

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

Changelog

  • Deduplicate merged PR entries in preview by BYK in #690
  • Disable author mentions in PR preview comments by BYK in #684

Other

  • (github) Clean up orphaned draft releases on publish failure by BYK in #681
  • (publish) Fail early on dirty git repository by BYK in #683

🤖 This preview updates automatically when you update the PR.

@BYK BYK force-pushed the byk/fix/closed-changelog-preview branch from fb04caa to 0ce18e1 Compare December 30, 2025 18:28
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.
@BYK BYK force-pushed the byk/fix/closed-changelog-preview branch from 0ce18e1 to 68836bc Compare December 30, 2025 18:34
@BYK BYK marked this pull request as ready for review December 30, 2025 18:38
@BYK BYK enabled auto-merge (squash) December 30, 2025 18:38
@BYK BYK merged commit bca393e into master Dec 30, 2025
14 checks passed
@BYK BYK deleted the byk/fix/closed-changelog-preview branch December 30, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants