Skip to content

About

Restore test reports and notes after a Git worktree is gone. A local, SHA-256 verified CLI for macOS and Linux.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

worktree-keep

Save the test reports and notes that exist only in a disposable Git worktree. Restore them after the worktree is gone, even if you no longer have the checkout.

$ wtkeep scan reports notes
untracked          34  notes/device-run.md
ignored           172  reports/unittest.txt
2 file(s)
$ wtkeep save reports notes
Saved <snapshot-id> (2 files)
$ wtkeep restore <snapshot-id> --to ./recovered
Restored <snapshot-id> (2 files) to recovered

The example uses a placeholder ID. wtkeep list retrieves your actual IDs from the local store. Each snapshot keeps the selected files, their repository-relative paths, their sizes and a SHA-256 digest per file.

Try an actual recovery

On macOS or Linux, with Git and Python 3.10+:

git clone https://github.com/erossx/worktree-keep.git
cd worktree-keep
python3 examples/verify_recovery.py

The demo creates a temporary linked worktree, runs a real test, and writes its report and a Korean-language note. It saves them, removes the original worktree with Git, verifies that the directory is gone, and restores both files elsewhere. It checks the restored bytes against the originals and prints their hashes. All Git operations run inside the demo’s own temporary directory.

Install

Download wtkeep.pyz and SHA256SUMS from the same release. In the download directory:

# macOS: verify the downloaded file. On Linux use sha256sum -c SHA256SUMS.
shasum -a 256 -c SHA256SUMS
python3 wtkeep.pyz --help

Use python3 /path/to/wtkeep.pyz anywhere the examples show wtkeep. For the shorter installed command, install from a tagged source checkout using pipx install . or run:

pipx install 'git+https://github.com/erossx/[email protected]'

Choose what survives

  1. In your worktree, run wtkeep scan to see Git-ignored and untracked regular files. For a large tree, narrow the scan with wtkeep scan reports notes. Each listed file’s size is in bytes.
  2. Pass the desired files or directories to wtkeep save. Paths are literal and relative to the repository root, including when you run the command from a subdirectory. A directory recursively selects eligible files inside it. An empty eligible selection produces an error. Use -- before names beginning with a dash.
  3. Allow your normal cleanup to proceed after save exits successfully. Run wtkeep list and wtkeep restore ID --to NEW_DIRECTORY from any directory to recover the snapshot. Choose a new directory under an existing parent. The restore checks every file’s size and digest before publishing the directory.

To reuse a selection, create a UTF-8 .wtkeep file at the repository root and call wtkeep save after your test or note-writing step, while the worktree still exists. Track the configuration in Git if you want new linked worktrees to inherit the selection.

# .wtkeep — one literal file or directory per line
reports
notes/device-run.md

If you use Worktrunk, add the following to your project's .config/wt.toml and approve the hook in Worktrunk. With hooks enabled, Worktrunk runs it inside the worktree before removal. A failed save stops that removal. Direct deletions by other tools have their own lifecycle, so call wtkeep save at the end of the task for those tools. Worktrunk hook documentation

[pre-remove]
keep-results = "wtkeep save"

Save each time you want a recovery point. A file must already exist to be saved. If a running test or database is writing to a selected file, let it finish or produce a consistent export first. The copy detects files that change during reading. A multi-file snapshot of a live database requires the database’s own backup mechanism.

Store and output

Option or command Behavior
--store DIRECTORY or WTKEEP_STORE Use a dedicated, private directory outside the worktree. The CLI flag takes precedence. Use an absolute path to access the same store from different working directories.
Default on macOS ~/Library/Application Support/wtkeep
Default on Linux $XDG_DATA_HOME/wtkeep, falling back to ~/.local/share/wtkeep
--json Machine-readable scan, manifest, or snapshot listing. Works before or after the command.
scan --repo PATH / save --repo PATH Select the checkout containing PATH.
list / restore Work from the snapshot store even if the worktree is deleted.

Each save makes a local copy. Space use grows with the selected data. The store is owner-only and files are unencrypted. Saving a whole directory includes eligible secrets and caches inside it, so choose specific output paths. Git tracks the source code; wtkeep handles local artifacts. Symbolic links, nested Git repositories, tracked files and empty directories are excluded. Recovery covers file contents and relative paths. Keep the store itself if you need recovery after a disk failure.

Verify a build

python3 -m unittest discover -s tests -v
python3 scripts/build_zipapp.py
python3 examples/verify_recovery.py --tool dist/wtkeep.pyz

The test suite also covers damaged payloads, invalid manifests and existing restore targets. The CLI uses Python’s standard library, Git, and macOS/Linux exclusive rename support. A filesystem that cannot publish without overwriting an existing destination will report an error.

한국어 사용 안내 · MIT license

About

Restore test reports and notes after a Git worktree is gone. A local, SHA-256 verified CLI for macOS and Linux.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages