diff --git a/CLAUDE.md b/CLAUDE.md index 3aada8c..e7ffd49 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 diff --git a/README.md b/README.md index 6dc5d03..ae93fe3 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ git gtr new my-feature --name descriptive-variant - `--track `: 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 `: Custom folder name suffix (optional, required with --force) - `--folder `: Custom folder name (replaces default, useful for long branch names) diff --git a/bin/gtr b/bin/gtr index f770322..6b7a4bf 100755 --- a/bin/gtr +++ b/bin/gtr @@ -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="" @@ -160,6 +161,10 @@ cmd_create() { skip_fetch=1 shift ;; + --no-verify) + skip_hooks=1 + shift + ;; --yes) yes_mode=1 shift @@ -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" @@ -1548,6 +1555,7 @@ CORE COMMANDS (daily workflow): --track : 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 : custom folder name suffix (e.g., backend, frontend) --folder : custom folder name (replaces default, useful for long branches) diff --git a/completions/_git-gtr b/completions/_git-gtr index 5811013..fc248ae 100644 --- a/completions/_git-gtr +++ b/completions/_git-gtr @@ -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:' \ diff --git a/completions/git-gtr.fish b/completions/git-gtr.fish index b8b396b..51ad328 100644 --- a/completions/git-gtr.fish +++ b/completions/git-gtr.fish @@ -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 diff --git a/completions/gtr.bash b/completions/gtr.bash index d486d73..5cbd3e5 100644 --- a/completions/gtr.bash +++ b/completions/gtr.bash @@ -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 diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 24049ed..3d012bc 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -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 | ---