Conversation
📝 WalkthroughWalkthroughDefaults for copy hooks now apply in-place: when a Changes
Sequence Diagram(s)sequenceDiagram
participant Runner as "PostCreate Runner"
participant Exec as "Hook Executor"
participant OS as "OS (stat / samefile)"
participant FS as "Filesystem (mkdir/copy/symlink)"
rect rgba(200,200,255,0.5)
Runner->>Exec: invoke copy/symlink hook (from, to)
end
rect rgba(200,255,200,0.5)
Exec->>OS: os.Stat(from) -> srcInfo
Exec->>OS: os.Lstat(destination) -> dstInfo (if exists)
OS-->>Exec: srcInfo, dstInfo
end
rect rgba(255,200,200,0.5)
Exec->>OS: os.SameFile(srcInfo, dstInfo)?
OS-->>Exec: sameFile? (true/false)
Exec-->>Runner: error "source and destination paths must be different" (if true)
end
rect rgba(200,255,255,0.5)
Exec->>FS: mkdir destination dir (if needed)
Exec->>FS: perform copy or create symlink
FS-->>Exec: success/failure
Exec-->>Runner: result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR enhances the copy hook functionality by making the to field optional, defaulting it to the from value when omitted. This provides a convenient shorthand for the common case where files are copied to the same relative path in the new worktree.
Changes:
- Modified validation logic to allow omitting the
tofield for copy hooks and automatically default it tofrom - Updated loop iteration to modify hooks by reference, enabling in-place default assignment
- Added comprehensive test coverage for the new defaulting behavior
- Updated documentation in README and architecture docs to explain the shorthand
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/config/config.go | Modified validation to default to field to from when empty; changed loop to use index-based iteration for in-place mutation |
| internal/config/config_test.go | Updated test expectations and added new tests to verify default behavior at hook and config levels |
| README.md | Added documentation comments and examples showing the to field can be omitted |
| docs/architecture.md | Added note explaining the default behavior for copy hooks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 573df4f0c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Closes #75.
Testing
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.