sp export/import — move the store between machines - #36
Merged
Conversation
7 tasks
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.
Closes #33
Adds
sp export/sp import: a dependency-free way to snapshot the whole store as a single.tar.gzand restore it on another machine. Stdlibarchive/tar+compress/gziponly — no new deps.Export
sp export [--out FILE] [--include-morgue]— bundles a self-describing manifest plus each scratch's content.scratchpatch-export-<timestamp>.tar.gzin cwd;--out FILEfor a path;--out -streams to stdout.--include-morguealso archives morgued ones (they land back in the morgue on import).Import
sp import <FILE>(or-for stdin).--merge(default): adds incoming scratches, keeps existing on id collision and reports skips — never clobbers content.--replace: explicit + destructive-safe — writes a timestamped backup tarball next to the store root, then replaces the store.Design. Exports ship a manifest of exactly the bundled scratches (not the raw
index.json), so merge/replace stay honest. Entry paths mirror the on-diskscratches/andmorgue/layout. A schema version guards the format.Tests. Store-level: round-trip content + metadata (tags/timestamps preserved), merge collision handling, empty-store export, include-morgue, replace-backs-up-and-replaces, non-export rejection. CLI-level: full export→fresh store→import round-trip via files, and the --merge/--replace conflict guard.
README updated with an export/import section (merge-vs-replace note) + quickstart lines.
All acceptance criteria met.
go build,go vet, and fullgo test ./...green.