Repository navigation
merge_check: say when a PR is already on main without a merge of its own (stacked PRs) - #8666
berkay8987 wants to merge 1 commit into
Conversation
A stacked PR squash-merged inside the PR above it, or a change that landed under another commit, has no merge under its own number, so the script called it `clean` (or `conflict` once main had edited its lines), never "already on main". - `already-on-main`: no merge of the PR is found, but the conflict-free merged tree matches main, so merging it changes nothing. - `on_main_outside_conflicts`: with a conflict, whether the merge with every conflicting hunk resolved to main's side (merge-tree -X ours) leaves main as it is. The verdict stays `conflict`; null where git cannot make that merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 68a3362 on Linux, Python 3.14.4, git 2.53.0: pass
|
|
Verified 68a3362 against main 6312c05 (clean merge, tree 7f5326485; recheck clean at 5d74c27). tests/test_merge_check.py on the merged tree: Ran 19, OK (re-run; incl. the re-targeted #999/sq2 assertion — its content is on main, so already-on-main with exit 1 is the honest verdict). Same file on clean main: FAILED (failures=2, errors=2). Mutation probes: forcing on_main_outside_conflicts=True turns the conflicting-PR test red (1F); neutering the already-on-main branch turns two red (2F); restores verified clean. No supersession: main has no equivalent verdict path. Flag: no CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Checked
Host caveat: this machine has Python 3.15 while CI pins 3.12; nothing in the hunk is version-sensitive. AI-assisted: yes (Windows host, CPU-only, no GPU and no game files). |
|
Tested 68a3362 on Windows 11 (NTFS), Python 3.12.10, git 2.53.0.windows.2 (CPU only, no GPU, no game files): pass The earlier comments cover the unit tests, the negative control and the modify/delete fallback. I added an end-to-end run on a hand-built repository, a check that the script stays offline and read-only, and the overlap with #8807. What I ran:
The exit code is 1 for both versions on this batch. The extra
Nit, not blocking:
Overlap: #7468, #7660 and #8291 conflict with this PR, as the description says. #8807 (yours, "a merge that main has reverted no longer counts as a prior merge") conflicts too, in AI-assisted (Claude Code). |
Claimed in the coordination issue as: new BUILD item, #8504 (comment)
Depends on: #7468, #7660 and #8291, in the sense the template asks for: each edits
scripts/merge_check.pyclose to the lines this one does andgit merge-treereports a conflict with each, so whichever lands second needs a small rebase. It also goes together with #8564 (no textual conflict); #8564's commit3198b20keeps its--depth 5000test true with this change.What and why
already-mergedneeds a merge under the PR's own number ("Merge pull request #N" or a subject ending in "(#N)"). A PR whose change landed another way never has one:The script calls those
clean, orconflictonce main has edited their lines, never "already on main". Both versions of the script on the real PRs, read-only, againstmain867d922f:cleanalready-on-maincleanalready-on-mainconflictconflict, nothing outside the conflictsconflictconflict, nothing outside the conflictsconflictconflictTwo additions:
already-on-main: no merge of the PR is found, but the conflict-free merged tree matches main, so merging it changes nothing. It ranks afteralready-mergedand beforeduplicates, and exits 1 like every verdict butclean.on_main_outside_conflicts(a JSON field, and a clause in the text line): with a conflict, whether the merge with every conflicting hunk resolved to main's side (merge-tree -X ours) leaves main as it is. The verdict staysconflict, because a PR whose every change conflicts looks the same; it is a hint for whoever reads the report, not a verdict. It isnullwithout a conflict and where git cannot make that merge (a conflict-X oursdoes not settle, or a git whosemerge-treetakes no-X), so the script still runs on git 2.38.One existing expectation changes. In
test_a_multi_commit_squash_merged_pr_is_already_merged_despite_cherry_miss,999=sq2still finds no merge of #999, which is what that check is about; butsq2's content is on main, so it now readsalready-on-main(exit 1) instead ofclean.Tested
python -I tests/test_merge_check.pyon this branch's tree: 19 tests, OK (16, plus 3 new: a stacked PR squash-merged inside the one above it; the same once main edits its lines; a conflicting PR that adds more, which is not said to be on main). With the script change taken out, the three new tests and the changed999=sq2check fail.python -m compileallandpython -I scripts/check_no_game_data.pyon both files: OK.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (No translator rule here.)🤖 Generated with Claude Code