fast gates: deepen a pull request's checkout so a head that brings the base in is not read as adding the whole tree

Merged
TE
13d ago
+81-25

The prepush "Sidebar-Look:" check in Fast gates on the merge fails a PR whose head commit brings the base in, even when the PR doesn't touch the sidebar.
Leo: "The fast-gates sidebar-look-owner false red that fails every PR must diff against the real merge base."

Why it happens: on #24526 at 3a47dc1f it reported 162 sidebar files. The pull_request checkout holds the merge ref at depth 2, which is the merge and its two parents. The PR head's own parents are cut off, so git treats the head as a root commit that adds the whole tree, and rev-list --no-merges keeps it even when it is a merge, because a cut merge shows no parents. Any per-commit gate reads it the same way. transcript-parity got past it by rebasing #24526 to an identical tree (a7e8cfef), but every lane that updates from base would hit it.

Fix: prepare deepens the pull_request checkout using the rule the dispatch path already uses, now shared as deep_enough and deepen: keep deepening until the base meets the head at its true merge base, with no cut between them. A full clone is left alone, as before.

Tests

  • New: test_pull_request_deepens_so_a_head_that_brings_the_base_in_is_not_a_cut. It sets up a depth-2 merge-ref checkout, the same thing actions/checkout fetches, whose head brings the base in. After prepare, rev-list --no-merges base..merge is only the PR's own commit, and that commit's diff lists only its own file. On the old script the test fails, listing the cut merge commit instead.
  • New: test_pull_request_in_a_full_clone_fetches_nothing_more.
  • tests/test_cmux_next_fast_gates.py: 59 tests, OK. tests/test_ci_no_shallow_dev_fetch.py: OK.

Observed / Not run

  • Observed: both test files above, run locally (Python only, no build).
  • Not run: this workflow on a real PR; this PR's own Fast gates run is the first.

Changelog

none

Agent session: huge-blue

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes the "Sidebar-Look:" prepush check failing a PR whose head commit brings the base in, even when the PR doesn't touch the sidebar — on #24526 it reported 162 sidebar files.

The pull_request checkout holds the merge ref at depth 2, cutting the PR head's own parents, so git reads the head as a root commit that adds the whole tree (rev-list --no-merges keeps it because a cut merge shows no parents). prepare now deepens pull_request checkouts with the rule the dispatch path already used, extracted into shared deep_enough/deepen: keep deepening until the base meets the head at its true merge base, with no cut between them. A full clone is left alone, as before.

Tests

  • New test sets up a depth-2 merge-ref checkout whose head brings the base in; after prepare, rev-list --no-merges base..merge lists only the PR's own commit. Fails on the old script.
  • New test confirms a full-clone pull_request fetches nothing more.