Skip to content
This repository was archived by the owner on Oct 22, 2026. It is now read-only.

fix: use last PR number in commit subject for revert commits - #277

Open
skyc1e wants to merge 1 commit into
MetaMask:mainfrom
skyc1e:fix/revert-commit-pr-number
Open

skyc1e wants to merge 1 commit into
MetaMask:mainfrom
skyc1e:fix/revert-commit-pr-number

Conversation

@skyc1e

@skyc1e skyc1e commented Mar 28, 2026 •

Copy link
Copy Markdown

Summary

Fixes MetaMask/release-tools#119

When a revert commit includes the original PR number in its quoted title, the regex matched the first (#NNNN) instead of the actual revert PR number:

Revert "Remove useRequestQueue toggle (#4941)" (#5065)
^^^^^ ^^^^^
matched ignored (actual PR)

This caused the revert commit to be filtered out as a duplicate because #4941 was already in the changelog from a previous release.

Fix

Changed subject.match(/\(#(\d+)\)/u) (returns first match) to subject.matchAll() + take the last match. GitHub always appends the actual PR number at the end of the subject on squash merge, so the last (#NNNN) is always the correct one.

Test

Added a dedicated test case that simulates a revert commit with the original PR already logged — confirms the revert is now correctly included with its own PR number.

Test plan

  • All 14 get-new-changes tests pass (including new revert test)
  • Existing tests unaffected — normal commits still extract PR number correctly

Note

Low Risk
Low risk: a small, targeted change to PR-number extraction from git commit subjects plus a focused unit test; main risk is altered parsing for unusual subjects containing multiple (#NNNN) patterns.

Overview
Fixes PR-number extraction in getNewChangeEntries to use the last (#NNNN) occurrence in a commit subject (via matchAll), preventing revert commits that mention the original PR from being mis-identified and incorrectly deduplicated.

Adds a unit test covering a revert subject like Revert "... (#4941)" (#5065) to ensure the revert PR (#5065) is kept even when the original PR is already logged.

Written by Cursor Bugbot for commit a8ef164. This will update automatically on new commits. Configure here.

When a revert commit includes the original PR number in its quoted
title (e.g. `Revert "some change (#4941)" (#5065)`), the PR number
regex matched the first occurrence (#4941) instead of the actual
revert PR (#5065). This caused the revert to be incorrectly filtered
out as a duplicate if the original PR was already in the changelog.

Now uses `matchAll` to find all PR number patterns and takes the last
one, which is always the actual PR number appended by GitHub on
squash merge.

Fixes #213
@MetaMask MetaMask locked and limited conversation to collaborators Oct 22, 2026
@GuillaumeRx

Copy link
Copy Markdown
Contributor

This library has now been migrated into the release-tools monorepo. This PR has been locked and this repo will be archived shortly. Going forward, releases of this library will only include changes made in the release-tools repo.

  • Please push this branch to release-tools and open a new PR there.
  • Optionally, add a link pointing to the discussion in this PR to provide context.

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commits that revert other commits don't get copied into the Unreleased section

2 participants