Skip to content

Commit f32a829

Browse files
committed
Remove switch command and related tests
1 parent 34aa104 commit f32a829

File tree

4 files changed

+1
-229
lines changed

4 files changed

+1
-229
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ fzf-git-worktree i, init # Setup "fzf-git-worktree" in current direct
4444
fzf-git-worktree new <name> # Create new worktree with branch <name> if it doesn't exist
4545
fzf-git-worktree rm, remove <name> # Remove worktree
4646
fzf-git-worktree ls, list # List worktrees
47-
fzf-git-worktree s, switch # Switch to existing worktree interactively
48-
fzf-git-worktree s -c <name> # Create new branch and worktree with <name>
4947
fzf-git-worktree help # Print usage
5048
```
5149

@@ -54,7 +52,6 @@ fzf-git-worktree help # Print usage
5452
1. In your Git repository, run `fzf-git-worktree init` to set up the worktree structure
5553
2. Use `fzf-git-worktree new feature-x` to create a new worktree for your feature
5654
3. Switch between worktrees with `fzf-git-worktree` (interactive)
57-
4. Create new branch with worktree using `fzf-git-worktree switch -c feature-y`
5855

5956
## Testing
6057

tests/test_remove.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test_remove_with_path_argument() {
6565
test_remove_switches_directory_when_removing_current() {
6666
setup_worktree_repo
6767

68-
# Create a worktree and switch to it
68+
# Create a worktree and cd to it
6969
git worktree add ../feature1
7070
cd ../feature1
7171

tests/test_switch.zsh

Lines changed: 0 additions & 185 deletions
This file was deleted.

zsh-fzf-git-worktree.zsh

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ Usage:
2828
work new <n> create new work tree and switch to it
2929
work rm, remove <n> remove work tree
3030
work ls, list list work trees
31-
work s, switch switch to existing work tree interactively
32-
work s -c <name> create new branch and work tree with <name>
3331
work help print usage
3432
HEREDOC
3533
}
@@ -120,41 +118,6 @@ HEREDOC
120118
cd "$NEW_DIR"
121119
}
122120

123-
handle_switch_command() {
124-
shift # Remove 'switch' from arguments
125-
126-
# Check for -c option
127-
if [[ "$1" == "-c" ]]; then
128-
local NAME=$2
129-
if [[ -z "$NAME" ]]; then
130-
echo "FATAL: you need to provide a branch/worktree name"
131-
usage
132-
return 1
133-
fi
134-
135-
# Check if branch already exists
136-
if git branch --list "$NAME" | grep -q .; then
137-
echo "Branch '$NAME' already exists"
138-
return 1
139-
fi
140-
141-
# Create new branch and worktree
142-
local CURRENT_BRANCH=$(git branch --show-current)
143-
git worktree add -b "$NAME" "../$NAME" "$CURRENT_BRANCH"
144-
if [[ $? -eq 0 ]]; then
145-
local NEW_DIR=${CWD_PARENT}/${NAME}
146-
147-
if [[ -f "$CWD_PARENT/hook.sh" ]]; then
148-
bash "$CWD_PARENT/hook.sh" "$NEW_DIR"
149-
fi
150-
151-
cd "$NEW_DIR"
152-
fi
153-
else
154-
# No -c option, switch to existing worktree
155-
handle_switch
156-
fi
157-
}
158121

159122
handle_remove() {
160123
local NAME=$2
@@ -219,9 +182,6 @@ HEREDOC
219182
new)
220183
handle_new "$@"
221184
;;
222-
s|switch)
223-
handle_switch_command "$@"
224-
;;
225185
rm|remove)
226186
handle_remove "$@"
227187
;;

0 commit comments

Comments
 (0)