Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ git config gtr.hook.preRemove "exit 1"
# Expected: Removal aborted due to hook failure
./bin/gtr rm test-hook-fail --force
# Expected: Removal proceeds despite hook failure

# Test --no-verify flag
git config --add gtr.hook.postCreate "echo 'Created!' > /tmp/gtr-test"
./bin/gtr new test-no-verify --no-verify
# Expected: /tmp/gtr-test should NOT be created
ls /tmp/gtr-test 2>&1 # Should fail
./bin/gtr rm test-no-verify
git config --unset gtr.hook.postCreate
```

### Debugging Bash Scripts
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ git gtr new my-feature --name descriptive-variant
- `--track <mode>`: Tracking mode (auto|remote|local|none)
- `--no-copy`: Skip file copying
- `--no-fetch`: Skip git fetch
- `--no-verify`: Skip post-create hooks
- `--force`: Allow same branch in multiple worktrees (**requires --name or --folder**)
- `--name <suffix>`: Custom folder name suffix (optional, required with --force)
- `--folder <name>`: Custom folder name (replaces default, useful for long branch names)
Expand Down
18 changes: 13 additions & 5 deletions bin/gtr
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ cmd_create() {
local track_mode="auto"
local skip_copy=0
local skip_fetch=0
local skip_hooks=0
local yes_mode=0
local force=0
local custom_name=""
Expand Down Expand Up @@ -160,6 +161,10 @@ cmd_create() {
skip_fetch=1
shift
;;
--no-verify)
skip_hooks=1
shift
;;
--yes)
yes_mode=1
shift
Expand Down Expand Up @@ -313,11 +318,13 @@ cmd_create() {
fi
fi

# Run post-create hooks
run_hooks_in postCreate "$worktree_path" \
REPO_ROOT="$repo_root" \
WORKTREE_PATH="$worktree_path" \
BRANCH="$branch_name"
# Run post-create hooks (unless --no-verify)
if [ "$skip_hooks" -eq 0 ]; then
run_hooks_in postCreate "$worktree_path" \
REPO_ROOT="$repo_root" \
WORKTREE_PATH="$worktree_path" \
BRANCH="$branch_name"
fi

echo ""
log_info "Worktree created: $worktree_path"
Expand Down Expand Up @@ -1548,6 +1555,7 @@ CORE COMMANDS (daily workflow):
--track <mode>: tracking mode (auto|remote|local|none)
--no-copy: skip file copying
--no-fetch: skip git fetch
--no-verify: skip post-create hooks
--force: allow same branch in multiple worktrees (requires --name or --folder)
--name <suffix>: custom folder name suffix (e.g., backend, frontend)
--folder <name>: custom folder name (replaces default, useful for long branches)
Expand Down
1 change: 1 addition & 0 deletions completions/_git-gtr
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ _git-gtr() {
'--track[Track mode]:mode:(auto remote local none)' \
'--no-copy[Skip file copying]' \
'--no-fetch[Skip git fetch]' \
'--no-verify[Skip post-create hooks]' \
'--force[Allow same branch in multiple worktrees]' \
'--name[Custom folder name suffix]:name:' \
'--folder[Custom folder name (replaces default)]:folder:' \
Expand Down
1 change: 1 addition & 0 deletions completions/git-gtr.fish
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ complete -c git -n '__fish_git_gtr_using_command new' -l from-current -d 'Create
complete -c git -n '__fish_git_gtr_using_command new' -l track -d 'Track mode' -r -a 'auto remote local none'
complete -c git -n '__fish_git_gtr_using_command new' -l no-copy -d 'Skip file copying'
complete -c git -n '__fish_git_gtr_using_command new' -l no-fetch -d 'Skip git fetch'
complete -c git -n '__fish_git_gtr_using_command new' -l no-verify -d 'Skip post-create hooks'
complete -c git -n '__fish_git_gtr_using_command new' -l force -d 'Allow same branch in multiple worktrees'
complete -c git -n '__fish_git_gtr_using_command new' -l name -d 'Custom folder name suffix' -r
complete -c git -n '__fish_git_gtr_using_command new' -l folder -d 'Custom folder name (replaces default)' -r
Expand Down
2 changes: 1 addition & 1 deletion completions/gtr.bash
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ _git_gtr() {
new)
# Complete flags
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--id --from --from-current --track --no-copy --no-fetch --force --name --folder --yes --editor -e --ai -a" -- "$cur"))
COMPREPLY=($(compgen -W "--id --from --from-current --track --no-copy --no-fetch --no-verify --force --name --folder --yes --editor -e --ai -a" -- "$cur"))
elif [ "$prev" = "--track" ]; then
COMPREPLY=($(compgen -W "auto remote local none" -- "$cur"))
fi
Expand Down
1 change: 1 addition & 0 deletions docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ git gtr rm ci-test --yes --delete-branch
| `--yes` | Skip all confirmation prompts |
| `--no-copy` | Skip file copying (faster) |
| `--no-fetch` | Skip git fetch (use existing refs) |
| `--no-verify` | Skip post-create hooks |
| `--delete-branch` | Delete branch when removing worktree |

---
Expand Down