Conversation
Support "." as a special argument in wt remove, open, cd, and apply to target the worktree the user is currently inside. This parallels the existing "wt cd .." shorthand for the project root. For wt remove, when the user is inside the target worktree, the process chdir's to the project root before invoking git worktree remove, and prints the project root to stdout so the shell wrapper auto-cd's the user there seamlessly. Also extracts selectWorktree/findWorktreeByBranch helpers to DRY up the duplicated worktree resolution logic across all four commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.as a special argument towt remove,wt open,wt cd, andwt applyto target the worktree the user is currently inside (works from subdirectories too)wt remove ., the process chdir's to the project root before git removes the directory, then the shell wrapper auto-cd's the user to the project root seamlesslyremoveto the shell wrapper's intercepted commands (bash, zsh, fish) so the auto-cd worksselectWorktreeandfindWorktreeByBranchhelpers to DRY up duplicated worktree resolution logic across all four commands.to tab completion for discoverabilityTest plan
make devpasses (fmt, lint, tests, build)cd worktrees/<branch> && wt open .opens current worktree in editorcd worktrees/<branch> && wt cd .prints current worktree pathcd worktrees/<branch> && wt apply .applies shared files to current worktreecd worktrees/<branch> && wt remove .removes worktree and shell lands at project root (with wrapper)cd worktrees/<branch>/some/subdir && wt open .resolves correctly from subdirectorywt remove .returns "not inside a managed worktree" errorwt remove <branch>while inside that worktree also works seamlessly (chdir protection fires for any targeting, not just.).in the listeval "$(wt shell-init zsh)"picks up the newremoveinterception