Skip to content

test: fix graft clobber-guard test on unsigned commits (CI)#12

Open
flipvh wants to merge 1 commit into
mainfrom
fix/sync-base-graft-test-unsigned
Open

test: fix graft clobber-guard test on unsigned commits (CI)#12
flipvh wants to merge 1 commit into
mainfrom
fix/sync-base-graft-test-unsigned

Conversation

@flipvh

@flipvh flipvh commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Problem

The withTemporarySyncBaseGraft test "never clobbers an existing replacement object on the HEAD commit" (added in #10) fails in CI:

git replace -f --graft <head> <parent>
error: new commit is the same as the old one

The test built its pre-existing replacement by grafting HEAD onto its own existing parent. That yields a byte-identical commit — which git refuses. It passed locally only because commit.gpgsign=true: stripping the signature during graft made the replacement differ. CI signs nothing, so the objects were identical.

This is purely a test-fixture issue; the withTemporarySyncBaseGraft helper is unaffected (its production graft always adds baseSha as a new parent, so it never produces an identical object).

Fix

Build the pre-existing replacement by grafting HEAD onto its existing parent plus a fabricated orphan commit (git commit-tree with a unique message, no parent). The extra parent guarantees the replacement object differs regardless of signing, and the orphan leaves upstreamBlockSha unreachable — so the test still exercises the existing-replacement guard rather than the native-ancestor guard.

Validation

  • Reproduced the CI failure locally with GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null (unsigned commits) → failed before, passes after.
  • Full suite green (137 passing) both signed and unsigned.

🤖 Generated with Claude Code

The 'never clobbers an existing replacement' test grafted HEAD onto its own
existing parent to create the pre-existing replacement. With commit signing off
(CI default), that produces a byte-identical commit and git refuses with 'new
commit is the same as the old one'. It only passed locally because commit.gpgsign
was on, so stripping the signature made the replacement differ.

Graft onto a fabricated orphan commit as an extra parent instead, so the
replacement object always differs regardless of signing. The orphan keeps
upstreamBlockSha unreachable, so the helper still exercises the existing-replacement
guard rather than the native-ancestor guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant