Repository navigation
scripts/merge_check.py: before a merge round, say whether a PR is already on main or would double text - #6355
Conversation
…eady on main or would double text Reports, for PR=REF pairs against main: earlier "Merge pull request #N" merges, how many of the PR's commits git cherry finds on main, whether merge-tree conflicts, and blocks of 3+ consecutive lines the merge would add that main's file already has (a block the PR moves is not counted; only .md/.txt/.rst blocks set the verdict). Replayed on main's last 2,000 merges: of 151 repeat merges, 37 are already-merged and 6 more double text; of 200 sampled first merges, none is flagged for text. Read-only, standard library only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shayderrr
left a comment
There was a problem hiding this comment.
Review
Reviewed change in PR #6355: scripts/merge_check.py: before a merge round, say whether a PR is already on main or would double text.
Scope: scripts/merge_check.py, tests/test_merge_check.py
Diff: +358 / -0 across 2 file(s).
The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.
Reviewed by shayderrr via automated batch review.
|
Thanks @lines9686-rgb - I went through scripts/merge_check.py: before a merge round, say whether a PR is already on main or wo... and the diff around |
Item: tooling for the "repeated merges" question under Decisions for the maintainer (@paratustra's finding on #4816), claimed in #6214 (#6214 (comment)). Depends on: none.
Problem. A rebased copy of a PR that is already on main gets merged again in a later round, and git keeps both copies of what it added. On main
561b65a8, among the last 2,000 merges, 130 PR numbers are merged twice or more (151 repeat merges). Some of the doubled text is still on main (#2473 inembedded_shaders.md, #2899's 48 lines ofanimation.md, #3246 ingbuffer.md, #2519 inmodels.md).What this adds.
scripts/merge_check.py, read-only, standard library only, to run before a round:Per PR: earlier
Merge pull request #PRmerges on main; how many of its commitsgit cherryfinds on main already; whethergit merge-tree --write-treeconflicts; and blocks of three or more consecutive lines (each 40+ characters) that the merge would add while main's file already has them in the same order. A block the PR moves keeps its count and is not reported, and only.md/.txt/.rstblocks set the verdict, since equal lines in two functions are ordinary in code (they are still listed). Verdictalready-merged,duplicates,conflictorclean; exit 1 if any PR isn't clean.Replayed on history (each merge M checked as
--main M^1 PR=M^2, i.e. what the script would have said just before it):It flags all four of the cases above. A plain per-line check gave 89 false "duplicates" on the first merges (code repeats lines legitimately), hence the three-line blocks and the text-file rule. The 76 clean repeats are mostly follow-up pushes after a first merge, which a "same number already merged" rule alone would wrongly block.
Tested:
tests/test_merge_check.py(8 cases on throwaway repos: a fresh PR, a rebased copy of a merged PR, the same paragraph under another PR number, a moved block, a follow-up commit, one or two repeated lines, short lines, usage errors), Windows 11, Python 3.12, git 2.54, with an ASCII and a Cyrillic TEMP;compileall; thetests/test_docs_*.py,test_ci_registrationandtest_text_write_line_endingschecks. Needs git 2.38+ formerge-tree --write-tree. No game files. AI-assisted (Claude Code).🤖 Generated with Claude Code