Skip to content

feat: symlink preserved files instead of copying them#174

Merged
raphi011 merged 1 commit into
mainfrom
preserve
Apr 10, 2026
Merged

feat: symlink preserved files instead of copying them#174
raphi011 merged 1 commit into
mainfrom
preserve

Conversation

@raphi011

Copy link
Copy Markdown
Owner

Replaces the copy-based preserve system with symlinks so that edits to preserved files (e.g. .env) propagate instantly across all worktrees. The source of truth is now the repo root directory (containing .git/), and patterns are replaced with literal relative paths.

Breaking Changes

  • preserve.patterns renamed to preserve.paths (literal relative paths, no globs)
  • preserve.exclude removed entirely
  • Existing worktrees with copied files are unaffected (symlinks only for new worktrees)

Test Coverage

  • Unit tests added: 9 (TestLinkFile: 5, TestPreserveFiles: 4)
  • Integration tests added: 4 (TestPreserveFiles: symlink creation, missing source, existing dest, edit propagation)
  • Unit tests updated: TestValidatePreservePaths, TestMergeLocal_PreserveAppendDedup, config load tests
  • Integration tests updated: TestCheckout_PreserveFiles, TestCheckout_PreserveNoOverwrite, TestCheckout_NoPreserveFlag
  • Integration tests removed: TestCheckout_PreserveExclude (exclude config removed)

🤖 Generated with Claude Code

@codecov

codecov Bot commented Apr 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/preserve/preserve.go 72.41% 5 Missing and 3 partials ⚠️
cmd/wt/config_cmd.go 50.00% 1 Missing and 1 partial ⚠️
cmd/wt/checkout_cmd.go 85.71% 0 Missing and 1 partial ⚠️
internal/config/config.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Replace the copy-based preserve system with symlinks so that edits to
preserved files (e.g. .env) propagate instantly across all worktrees.

- Source of truth is now the repo root (directory containing .git/)
- Patterns replaced with literal relative paths (preserve.paths)
- Removed exclude config (no longer needed with explicit paths)
- Removed FindSourceWorktree, FindIgnoredFiles, matchesPattern, CopyFile
- Added LinkFile (relative symlinks), ErrDestExists sentinel
- Warns when destination already exists in worktree

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raphi011
raphi011 merged commit bdee928 into main Apr 10, 2026
2 checks passed
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.

1 participant