Skip to content

[plan] Linearize rewrite against agent's own base commit, not moving branch tip #48994

Description

@github-actions

Objective

Fix linearizeRangeAsCommit in actions/setup/js/git_helpers.cjs so the rewrite path diffs against the agent's actual base commit instead of the current (possibly moved) origin/<base> tip.

Context

When a shallow checkout forces the signed-push rewrite path (merge commit detected in the bogus full-history range), the code does:

await execApi.exec("git", ["reset", "--soft", baseRef], ...execArgs);

where baseRef is origin/<base> (set in create_pull_request.cjs:333, used at :346). If the base branch has moved since the agent's checkout, this soft-reset leaves the index at the new tip's tree, so git diff --cached --name-only computes diff(base_tip_tree, agent_head_tree) instead of diff(agent_base_tree, agent_head_tree). This causes the synthesized commit to revert unrelated base-branch drift and delete files added to base after checkout, attributing them to the agent.

Suggested Approach

  1. Locate linearizeRangeAsCommit in actions/setup/js/git_helpers.cjs.
  2. Instead of resetting to origin/<base> tip, reset/diff against the bundle's actual base commit — the prerequisite SHA already extracted by extractBundlePrerequisiteCommits — which represents the agent's true base at checkout time.
  3. Alternatively, use git commit-tree to squash against that base commit directly rather than soft-reset + diff.
  4. If the resulting commit needs to sit on the current branch tip, rebase it onto the tip rather than absorbing tip differences into the diff.
  5. Add/update tests simulating a moving base branch (commits added to base after the agent's checkout) and assert the synthesized commit only contains the agent's actual changes.

Files to Modify

  • actions/setup/js/git_helpers.cjs (function linearizeRangeAsCommit)
  • actions/setup/js/create_pull_request.cjs (baseRef computation around line 333/346, if needed)
  • Relevant test files under actions/setup/js/*.test.* or equivalent

Acceptance Criteria

  • Rewrite path no longer reverts base-branch commits added after the agent's checkout
  • Rewrite path no longer includes files matching excluded-files/allowed-files restrictions unless the agent actually touched them
  • New/updated tests cover a moving-base-branch scenario with a merge commit forcing the rewrite path
  • Existing tests pass

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions