Repository navigation
Carry synced files onto an existing sync branch that holds another copy [patch] - #349
Open
matt-edmondson wants to merge 3 commits into
Open
matt-edmondson wants to merge 3 commits into
matt-edmondson wants to merge 3 commits into
Conversation
…py [patch]
sync copies files into each repository before switching to the sync
branch. When the branch already exists and holds a different copy of a
synced file, as on every re-run while a sync PR is open, a plain
checkout refuses ("would be overwritten by checkout"). The repo was
skipped, and the copied file stayed modified on the user's branch.
When the plain checkout fails and the only local changes are the files
sync wrote into that repo, save their content, force the checkout, and
write the content back so it is committed on the branch. Any other
local change, such as the user's own edits or untracked files, keeps the
refusal, so nothing of theirs can be discarded.
The test that pinned the old skip is replaced by one for the reuse case,
plus a guard that an unrelated user edit still blocks the switch.
Fixes #203
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW48r2AEHXkyMC1wF3i
…s repo once [patch] main fails restore on NU1903 (GHSA-v76p-62qx-wwq2) against 3.1.12, so no PR can build. This ports the bump from #270. SwitchReposToBranchAsync now looks up each file's repository once and filters with Where. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW48r2AEHXkyMC1wF3i
Contributor
Author
|
CI: all three No fix can be ported here yet. The 3.2.0 bump from #270 fails the build in CI without a Six Labors license key, and no patched 3.1.x exists, so I reverted it. Details and the three options for a maintainer are in #348 (comment). Once one of them lands on Generated by Claude Code |
3.2.0 fails the build in CI without a Six Labors license key, so the bump is not a usable fix for NU1903. That decision belongs to the maintainer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW48r2AEHXkyMC1wF3i
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.
Fixes #203
What was wrong
synccopies the chosen file into each repository's working tree first, and only then switches to the sync branch. When--branch Xnames a branch that already exists and holds a different copy of that file, a plaingit checkout Xrefuses with "Your local changes … would be overwritten by checkout", even if the new content matches the branch's copy. This happens on every re-run while a sync PR is still open.SwitchReposToBranchAsynccaught the error and skipped the repo, which left the copied file modified on the user's original branch (usuallymain) with nothing committed.Change
SyncGit.SwitchToSyncBranchAsyncnow takes the files sync wrote into that repository. If the plain checkout fails, it checksgit status. When the only local changes are those files, it saves their bytes, runscheckout --force, and writes them back. The normal commit step then commits them on the sync branch.SwitchReposToBranchAsyncpasses each repository its own files.I chose this over "switch before copying", which the triage suggested. That would have meant restructuring the interactive scan-and-copy flow in
RunAsync, because copying happens per file long before commit selection. This change stays inside the branch switch.Deviation from the acceptance criteria: when a switch still fails for an unrelated reason (the user's own edits block it), the copied file is kept on the original branch, as before, and is not discarded. Throwing it away there could destroy work, since #208 shows these paths can hold the user's own edits.
Tests
CommitFilesLeavesARepositoryUncommittedWhenItsCheckoutConflictspinned the exact behaviour this issue reports as a bug. It is replaced byCommitFilesReusesASyncBranchThatHoldsADifferentCopyOfTheFile, with two cases: new content that differs from the branch's copy, and new content identical to it. Each case checks that the content lands onsync/shared, that the original branch tip doesn't move, and that the original branch is left with the file unmodified andgit statusclean.CommitFilesLeavesARepositoryUncommittedWhenTheUsersOwnEditsBlockTheCheckout: an unrelated user edit that collides with the branch still blocks the switch, and both the edit and the copied file survive.With
KtsuTools.Sync/reverted, both reuse cases fail. The guard passes with or without the fix. Full suite with the fix: 387/387.Builds were run with
-p:WarningsNotAsErrors=NU1903, becausemaincurrently fails restore on the SixLabors.ImageSharp advisory (#270).Generated by Claude Code