Add --as <name> to tsk add for duplicate worktrees of the same repo - #3
Conversation
The worktree directory was always named after the repo's base name, so a second worktree of the same repo collided. --as <name> overrides the directory name (paired with -b for a distinct branch), defaulting to the base name when omitted. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
--as previously replaced the whole worktree directory name; it now appends -<suffix> to the repo's base name, so `tsk add --as hotfix ../gov-fr` produces gov-fr-hotfix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Thank you, Miguel!
For a parameter called --as I'd expect the full name to be provided, not just a suffix. At the end of the day, using the name of the repo as the default worktree name is just a convention. One that you may want to override occasionally (including but not limited to when you want the same repo twice, heaven knows why!).
So, I think I'd prefer that --as receives the full name: I think it's both more clear and more versatile.
Per review feedback, --as sets the full directory name (overriding the repo-name default) rather than appending a suffix -- clearer and more versatile. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds an --as <name> option to tsk add to allow adding the same source repo multiple times to a task by overriding the destination worktree directory name (while still requiring distinct branches).
Changes:
- Introduces
--asflag to override the worktree directory name and rejects--aswhen multiple repo paths are provided. - Adds
validWorktreeNamevalidation and corresponding tests for same-repo-twice, multi-repo rejection, and bad names. - Updates CLI usage text and README documentation with examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Documents adding the same repo twice and updates tsk add usage to include --as. |
| main.go | Implements --as flag wiring, validation, and directory name override in worktree creation. |
| main_test.go | Adds test coverage for --as behaviors and validWorktreeName. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func validWorktreeName(s string) bool { | ||
| if s == "" || s == "." || s == ".." { | ||
| return false | ||
| } | ||
| return !strings.ContainsRune(s, '/') && !strings.ContainsRune(s, filepath.Separator) | ||
| } |
Add
--as <name>totsk addso the same repo can be added twice.Changes:
🤖 Generated with Claude Code