Files
max-sixty__worktrunk/.worktreeinclude
T
Maximilian Roos bd2a7c16e9 feat(step): add copy-ignored command for syncing .worktreeinclude files (#469)
* feat(step): add copy-ignored command for syncing .worktreeinclude files

Add `wt step copy-ignored` to copy files listed in `.worktreeinclude` that
are also gitignored between worktrees. Useful in post-create hooks to sync
local config files (.env, IDE settings, build caches) to new worktrees.

Key features:
- Uses git ls-files --ignored for accurate gitignore handling (nested
  .gitignore, global excludes, .git/info/exclude)
- Uses ignore crate for .worktreeinclude pattern matching
- COW (reflink) copying for efficient large directory handling
- --directory flag stops at directory boundaries (avoids listing
  thousands of files in target/ or node_modules/)
- Skips existing files for idempotent hook usage
- Skips symlinks and .git entries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: update hook examples to use wt step copy-ignored

Replace manual CoW bash scripts with the new `wt step copy-ignored`
command in hook documentation. Update Rust and Node.js sections to
show `.worktreeinclude` patterns instead of complex shell commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add worktree-only branch completion filter

Add a new `worktree_only_completer()` function to filter branch completions
to only worktree branches, and update the `CopyIgnored` command to use it
instead of `local_branches_completer()` for the `--from` and `--to` arguments.

* Refactor hook documentation on copying files and CoW strategies

Replace the `.worktreeinclude` and `wt step copy-ignored` approach with direct
copy-on-write examples using native OS commands (`cp -c`, `cp --reflink=auto`).
Add comparison table of symlink vs copy vs CoW strategies with their tradeoffs.
Update language-specific sections (Rust, Node.js) to show CoW patterns instead
of `.worktreeinclude` configuration. Improve clarity on disk efficiency and
cross-platform fallback patterns.

* chore: use wt step copy-ignored for this repo

Add .worktreeinclude with target/ and replace the manual bash CoW
script with `wt step copy-ignored` in post-create hook.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: update all manual CoW examples to use wt step copy-ignored

Update cli.rs (source for hook docs) and tips-patterns.md to use the
new copy-ignored command instead of manual bash CoW scripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: use gutter format for dry-run output, sync skill files

- Refactor copy-ignored --dry-run to show files in a gutter list
  instead of printing each item separately
- Sync skill documentation files with docs (hook.md, step.md,
  tips-patterns.md) after rebase on main

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: simplify error handling in copy-ignored

- Use expect() for strip_prefix since paths always come from git ls-files
- Remove verbose .with_context() wrappers for simple errors - let them bubble up
- Reduces untestable code paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add idempotent and nested file tests for copy-ignored

- test_copy_ignored_idempotent: verifies running twice succeeds (AlreadyExists branch)
- test_copy_ignored_nested_file: copies single file in subdirectory

Improves coverage by exercising more code paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: fix copy-ignored tests to hit correct code paths

- test_copy_ignored_no_worktreeinclude: now creates worktree first
  so it hits the .worktreeinclude check instead of "same worktree"
- test_copy_ignored_empty_intersection: same fix
- Add test_copy_ignored_idempotent and test_copy_ignored_nested_file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test: add --to flag test for copy-ignored coverage

Adds test for the --to flag which specifies an explicit destination
worktree. This covers lines 437-439 which were previously uncovered.

Note: The .worktreeinclude parse error path (line 465) and copy error
path (line 524) remain untested because:
- The ignore crate is very lenient and doesn't return parse errors
- Filesystem copy errors are hard to test reliably cross-platform

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test: add .git skip coverage for copy_dir_recursive

Adds a .git file inside the target directory to test that
copy_dir_recursive correctly skips .git entries (line 598).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ci: trigger CI run

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-07 20:35:34 -08:00

5 lines
101 B
Plaintext

# Files to copy between worktrees (must also be gitignored)
# Used by: wt step copy-ignored
target/