fix: use last PR number in commit subject for revert commits#277
Open
skyc1e wants to merge 1 commit intoMetaMask:mainfrom
Open
fix: use last PR number in commit subject for revert commits#277skyc1e wants to merge 1 commit intoMetaMask:mainfrom
skyc1e wants to merge 1 commit intoMetaMask:mainfrom
Conversation
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 MetaMask#213
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.
Summary
Fixes #213
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
#4941was already in the changelog from a previous release.Fix
Changed
subject.match(/\(#(\d+)\)/u)(returns first match) tosubject.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
get-new-changestests pass (including new revert test)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
getNewChangeEntriesto use the last(#NNNN)occurrence in a commit subject (viamatchAll), 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.