Repository navigation
scripts/merge_check.py: detect squash-merged PRs as prior merges - #6669
Conversation
25dd843 to
e7d7ad8
Compare
|
Independent CPU review at
|
|
Merges clean with main; tests/test_merge_check.py passes 13/13 under -I and pytest, and 4 of the 5 new tests fail when the file runs against main's tool (control re-run: 3 failures + 1 error), so squash-merge detection is genuinely new behavior. The revert-subject exclusion and the merged-tree==main shortcut both check out, and the tool stays read-only stdlib. Flag: no CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested e7d7ad8 merged with main 511e382 on Windows/Python 3.13.1: pass scripts/merge_check.py needs git 2.38+ (
Diff read: prior merges are now first-parent commits whose subject is |
prior_merges() passed --merges and only matched "Merge pull request #N",
so squash-merged commits on main ("... (#N)") were never detected.
Also treat a conflict-free merge-tree whose output tree equals main's
tree as already-merged when a prior merge exists, so multi-commit PRs
that were squash-merged (where git cherry cannot match individual
pre-squash commits) are flagged while follow-up commits stay clean.
|
Rebased cleanly onto |
e7d7ad8 to
a027fa5
Compare
shayderrr
left a comment
There was a problem hiding this comment.
Summary
scripts/merge_check.py now recognizes squash-merge subjects ending in (#PR) on first-parent history, ignores Revert subjects, and treats a PR as already-merged when the conflict-free merged tree matches main even if git cherry finds no commits. Tests cover single/multi-commit squash merges, follow-up commits, revert subjects, and subject parsing.
Why merge
Squash-merged PRs were reported as not previously merged, which caused repeat-merge damage to go undetected. Matching the actual merge style and comparing trees makes the check correct for this repository's workflow.
Verdict: Approve
Summary
Why mergeSquash-merged PRs were reported as not previously merged, which caused repeat-merge damage to go undetected. Matching the actual merge style and comparing trees makes the check correct for this repository's workflow. Verdict: Approve |
Claimed in #6603 (#6603 (comment)). Follow-up to #6355.
Depends on: none (leaves
duplicates()untouched so it does not overlap with @DoubleD17's path-quoting claim in #6414).Problem
scripts/merge_check.pyonly looked for prior merges viagit log --merges --first-parentmatching^Merge pull request #(\d+)\b. Now that PRs are being squash-merged ontomainas single-parent commits ending with(#N)(including #6355 itself),prior_merges()missed all 50 of the latest squash-merged commits onorigin/main(1cc6e3cback 50 commits:0/50detected;check(".", "origin/main", 6294, "origin/main", ...)returnedmerges: [],verdict: "clean").In addition, when a multi-commit PR is squash-merged into one commit on
main,git cherry main refcompares each pre-squash commit individually and returnson_main = 0 < total, somerges and total == on_mainwould still not classify it asalready-merged.What changed
scripts/merge_check.py:--mergesfromprior_merges()and match bothMerge pull request #Nand trailing squash-merge subjects(#N)on--first-parentvia_merged_pr_number(), ignoringRevert ...subjects and earlier issue numbers in the title (e.g.... (#5515) (#5523)matches5523only;Merge pull request #7 ... (#99)matches7only).unchanged = not conflict and tree == rev_tree(repo, main)incheck()and classify the PR asalready-mergedwhenmerges and (total == on_main or unchanged). Follow-up commits pushed after a squash merge still change the merged tree and stayclean(orconflict). Whenalready-mergedis decided by an unchanged tree withon_main != total, text output notes, merged tree matches main; the JSON schema is unchanged.tests/test_merge_check.py:git cherryreports0/2(with unrelated changes onmainincluding a non-conflicting edit in the same file, plus checking that an earlier(#999)in the subject does not match), follow-up commit after multi-commit squash merge stayingclean,Revertcommits ignored, and_merged_pr_number()subject-parsing edge cases.Tested
python -I tests/test_merge_check.py -v: 13/13 passed.origin/main(1cc6e3c):0/50detected before,50/50detected after;check(6294=origin/main)now reportsalready-mergedwithmerges: ['1cc6e3c12196'].python -m compileall -q scripts/merge_check.py tests/test_merge_check.py: pass.python -I scripts/check_no_game_data.py scripts/merge_check.py tests/test_merge_check.py: pass.tests/test_ci_registration.py(14/14),tests/test_text_encoding.py(2/2),tests/test_check_no_game_data.py(8/8),tests/test_docs_cli_flags.py(3/3),tests/test_docs_repo_paths.py(3/3),tests/test_docs_python_deps.py(3/3) — all pass; both modified files verified LF-only (0 CRLF).AI-assisted.