Skip to content

[plan] Warn/fail on implausible commit range in shallow checkout before synthesizing rewrite commit #48996

Closed

Description

@github-actions

Objective

Add a sanity check that detects an implausible commit range (e.g., tens of thousands of commits for what should be a one- or few-commit branch) in a shallow checkout, and fail fast with a clear warning instead of proceeding to synthesize a potentially huge/incorrect rewrite commit.

Context

In a shallow checkout (default fetch-depth: 1), origin/<base> has no traversable ancestry, so git rev-list --parents --topo-order --reverse <origin/base>..HEAD cannot exclude anything and returns essentially the entire repository history (e.g., 61,008 commits for a repo with ~61k commits on main). This large range then trips merge-commit detection and forces the rewrite path (linearizeRangeAsCommit), which can produce an incorrect result (see companion issue about linearizing against the correct base). Detecting the implausible range early is far cheaper than synthesizing a multi-MB payload only to have it fail a size gate.

Suggested Approach

  1. Locate the code in actions/setup/js/git_helpers.cjs / create_pull_request.cjs that computes the commit range via git rev-list --parents --topo-order --reverse.
  2. After computing the range/count, compare it against a reasonable threshold (e.g., configurable, default maybe 50-100 commits) or compare against the known number of commits the agent's branch should have.
  3. If the range size is implausible for a shallow checkout, emit a clear warning/error log (e.g., "Shallow checkout produced an implausible commit range (N commits); consider increasing fetch-depth") and abort the push attempt (or fall back to requiring a deeper fetch) rather than proceeding to rewrite.
  4. Add a log message referencing the shallow-checkout condition so users can diagnose and apply the fetch-depth workaround.
  5. Add tests simulating a shallow checkout with a large synthetic commit range to verify the new guard triggers.

Files to Modify

  • actions/setup/js/git_helpers.cjs
  • actions/setup/js/create_pull_request.cjs
  • Relevant test files
  • Documentation: mention the fetch-depth workaround in relevant checkout/safe-outputs docs

Acceptance Criteria

  • A shallow checkout with an implausible commit range produces a clear, actionable warning/error before payload synthesis
  • Behavior is configurable or has a sane default threshold
  • Tests cover the new detection logic
  • Docs mention the fetch-depth workaround for large monorepos

Generated by 📋 Plan Command · aut00 · 18.7 AIC · ⌖ 5.78 AIC · ⊞ 6.8K · ◷
Comment /plan to run again

  • expires on Jul 31, 2026, 2:14 PM UTC-08:00

Activity

  1. added
    cookie
    on Jul 29, 2026
  2. github-actions commented on Jul 29, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · gpt54 · 5.76 AIC · ⌖ 6.67 AIC · ⊞ 7.8K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ai-generatedcookieplan

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions