Repository navigation
feat(sync): restore missing files and archive only with detach --archive - #857
Merged
Merged
Conversation
{{ message }}
Repository navigation
This repository is temporarily unavailable.
The backend storage is temporarily offline. Usually this means the storage server is undergoing maintenance. Please contact support if the problem persists.
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.
Context
A missing local file made sync archive the variation in LaunchDarkly. A file is often missing only because the working copy does not have it yet, for example after a Git pull or a branch switch. A plain sync, or a watch session that applies changes, could then archive a variation that other engineers use.
This PR is stacked on #856. That PR makes
sync.locktrack every project, so sync can find a variation whose file is missing.What changes
archive_serveraction is removed.ldcli sync prompts detach <selector> --archiveis the only way to archive a variation. It archives each selected variation in LaunchDarkly, and then stops syncing it.detach --archiveasks for confirmation in a terminal. With--no-input, it needs--yes, the same rule as other destructive changes.interactivepackage, so sync and detach use one copy.ldcli sync prompts, plural, like the other resource commands. There is no alias forsync prompt.Stop syncing a variation and archive it:
Review focus
detach --archivearchives?detach --archivesafe when a step fails: archive, then baseline, then file deletion?--no-input?Verification
go build ./...go vet ./...go test -race ./internal/sync/... ./cmd/sync/...TestPromptRestoresTrackedMissingFileInsteadOfArchivingdeletes a tracked file, runs sync, and checks that the file comes back and nothing is archived.Related changes
sync.lockdetach --archiveNote
Overview
Sync no longer archives missing local variations. A missing managed file (e.g. after
git pullor branch switch) is treated as restore from LaunchDarkly instead of pushing an archive. Thearchive_serverplan action and related conflict/diff paths are removed; server-side archive is only via detach.ldcli sync prompts detach --archiveoptionally archives selected variations in LaunchDarkly before stopping sync. Archive runs first (idempotent if already archived), then baseline and local cleanup; terminal confirmation or--yeswith--no-input. Sharedinteractive.Confirmpowers sync apply and detach archive prompts; conflict resolution usesSelectInlineso prior output stays visible.CLI rename:
sync prompt→sync prompts(examples/tests updated; no alias).Baseline /
sync.lock: Copies without a lock file no longer inherit the remote manifest as their baseline (avoids tracking other branches’ entries).versionis not written tosync.lock(versions stay on the remote manifest for optimistic updates).reffor linked variations is stored in the lock and used when recreating missing wrapper files; restore fails safely if the linked file is missing or diverges.Breaking: Scripts using
ldcli sync promptmust switch tosync prompts. Behavior change: deleting a tracked file and running sync restores it rather than archiving in LD.Reviewed by Cursor Bugbot for commit 3d1afe5. Bugbot is set up for automated code reviews on this repo. Configure here.