Fill the run workspace from the base commit, not by merging into it - #150
Merged
Merged
Conversation
A fix run clones at the pull request's own head (ADR-040), which is not on the default branch. The clone leaves no working tree and an empty index with HEAD still on that branch, so checkout -b was a two-way merge whose every edited file read as a phantom local change and refused. Point HEAD at the new branch first and hard-reset into the empty workspace: a one-way checkout with no prior state to conflict against. Every existing case seeded a default branch that only ADDED a file, so no path was ever in both trees with different content; the new test builds a branch that edits one and adds another.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
/fixon a pull request that EDITS an existing file never started: the init container exited 1 before the agent ran.Why
WorkspaceClone.populateclones withsetNoCheckout(true)— no working tree, empty index, HEAD still on the remote's default branch — and then runscheckout -b branch startPoint.That checkout is a two-way merge from the default branch's tree to the target's. A path present in both with different content reads as a local edit JGit must not silently overwrite, so it refuses the whole checkout. The index being empty is what makes the phantom edit.
Nothing meets this while the target commit is on the default branch, because then the two trees agree. A fix run is the case that is not: ADR-040 starts it at the pull request's own head, so the first file that pull request edits conflicts.
setForced(true)was tried and does not fix it — in JGit that forces the ref update, not the working-tree overwrite.The fix
Point HEAD at the new branch first, then fill the empty workspace from it with a hard reset. That is a one-way checkout: it writes the index and work tree from the target with no prior state to conflict against, which is exactly the situation — the workspace is empty by construction.
Why no test caught it
Every existing case seeds a default branch whose later commit only adds a file, so no path is ever in both trees with different content. The same held by luck in production: the only fix branch that had ever run,
demo/discount, added one file and edited none. Four fix runs passed on it.The new test builds the shape that was missing — a branch that edits one file and adds another — and asserts the resulting content, not merely the absence of a throw. Forcing the checkout without populating the work tree would pass a throw-only assertion and leave the run unit with an empty workspace.
Verification
:spire-workspace:test57 tests,:spire-publisher:test58,:spire-run-worker:test260 — 0 failures.M0WalkingSkeletonTest(real Docker, real git origin) green../gradlew testFast testServicesBUILD SUCCESSFUL.checkout -bfailsaPullRequestBranchThatEditsAFileCheckoutsOutCleanlyand nothing else — 6 tests, 1 failed.Impact
Every
/fixon a pull request that edits an existing file — most pull requests. The M2 loop worked only because the one branch it had ever run on added a file and edited none.Still open, not in this change
The row records
init container failed with exit 1. The real cause —CLONE_FAILED, the exception, the filename — reached only the container's stdout as structured JSON, and nothing salvages it intofailure_detail. Diagnosing this neededdocker logs, which is the gap the runs detail screen exists to close.