Skip to content

sp export/import — move the store between machines - #36

Merged
rwrife merged 1 commit into
mainfrom
issue-33-export-import
Jul 16, 2026
Merged

sp export/import — move the store between machines#36
rwrife merged 1 commit into
mainfrom
issue-33-export-import

Conversation

@rwrife

@rwrife rwrife commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Closes #33

Adds sp export / sp import: a dependency-free way to snapshot the whole store as a single .tar.gz and restore it on another machine. Stdlib archive/tar + compress/gzip only — no new deps.

Export

  • sp export [--out FILE] [--include-morgue] — bundles a self-describing manifest plus each scratch's content.
  • Defaults to scratchpatch-export-<timestamp>.tar.gz in cwd; --out FILE for a path; --out - streams to stdout.
  • Live scratches only by default; --include-morgue also 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-disk scratches/ and morgue/ 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 full go test ./... green.

@rwrife
rwrife merged commit 6e8c749 into main Jul 16, 2026
1 check passed
@rwrife
rwrife deleted the issue-33-export-import branch July 16, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] sp export/import — move the store between machines

1 participant