Repository navigation
[sync] Always overwrote synced files, and deleted each file once, since the last merged sync. - #9
Merged
Merged
Conversation
…ce the last merged sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Replaces the provenance rule of #7 and #8 with a simpler model:
ignore.Measuring deletions from the last merged sync, rather than from the push that triggered the run, means:
All the provenance and history comparison is gone.
Changes
scripts/last-sync.sh(new, its own workflow step): finds the source commit of the last sync this target merged, and exports it asSOURCE_SYNCED.GitHub-Graph-Sourcetrailer on this source directory's commit in the most recently merged sync PR. GitHub keeps PR commits after a merge, whether squashed or not and with the branch deleted.scripts/merge-files.sh: copies every non-ignored file in the source root, as before [sync] Deleted a file whose last change came from the source, however it first arrived. #7. It then deletes the target's copy of each file deleted betweenSOURCE_SYNCEDand the source's head (git diff --diff-filter=D), skipping ignored files. If that commit isn't in the source's history (say, after a force push), it warns and skips deletions. Over 90 lines are gone: the per-file history walks, the state map and theKeptreasons.scripts/publish.sh:GitHub-Graph-Source: <source commit>, after the key trailer. The PR body, which drops everything from the key trailer on, is unaffected.replay()goes back to applying every change as it is. No carry-forward is needed: this source's commit is rebuilt each time from everything since the last merged sync.load-config.sh.scripts/load-config.sh: exports the source directory's key (SYNC_KEY) and the two trailer names, forlast-sync.shandpublish.sh..github/workflows/sync.yml: a "Find last sync" step before "Merge files", given the target's token andgithub.event.before.README.md: "Which files are synced" describes the model: copy everything, delete once since the last merged sync, opt out withignore, and what a skipped run, a re-added file and a closed PR mean. "Merge semantics" says again that files are overwritten, that downstream changes are lost unless ignored, and that the most recent source wins.templates/pull-request-body.md: the default warning is back to its original text, which is accurate again.Testing
No CI exercises the scripts, so I ran them locally:
merge-files.sh, against a source and target with known histories:With no
SOURCE_SYNCEDit copied everything and deleted nothing. With a commit missing from the history, it warned and skipped deletions.last-sync.sh, withghstubbed:The real
--jqfilter, against SgtSwagrid/codeswitch's merged sync PRs: it found the latest merged sync commit from scala-browser-plugin-config by its key trailer. That commit predates the new trailer, so a live run would use the fallback until the next merged sync.The commit message:
%(trailers:key=…)reads both trailers, and the rendered PR body excludes them.replay(): an update, addition and deletion all apply onto a newer base, including over the target's changes. Deleting a file the target already deleted is a no-op.Syntax:
bash -npasses for every script.Notes
sync.yml@main, so once merged, the next sync of every target overwrites any local edits to synced files, as before [sync] Deleted a file whose last change came from the source, however it first arrived. #7.🤖 Generated with Claude Code