Conversation
This prevents the shell integration environment variable from being passed to hook commands, ensuring e2e tests run in a clean environment when executed through post-create hooks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix branch name extraction for -b/--branch options in shell integration - Properly handle worktree name detection for auto-cd functionality - Rename branch_name variables to worktree_name for clarity - Support all three shells (bash, zsh, fish) consistently 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughThe changes update shell integration logic for the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ShellFunction
participant wtp
User->>ShellFunction: wtp add [args] [-b branch]
ShellFunction->>ShellFunction: Extract worktree name from -b/--branch or positional arg
ShellFunction->>wtp: wtp cd <worktree_name>
wtp-->>ShellFunction: Returns directory path
ShellFunction->>ShellFunction: cd into returned directory
sequenceDiagram
participant HookExecutor
participant OS
HookExecutor->>OS: Get os.Environ()
HookExecutor->>HookExecutor: Filter out WTP_SHELL_INTEGRATION=*
HookExecutor->>OS: Execute hook command with filtered env
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Fixes issue where second argument parsing loop could not access original arguments after they were consumed by the first loop. This ensures auto-cd works correctly for all wtp add command variations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR addresses environment variable leakage and improves shell integration functionality for the wtp add command. The changes ensure hooks execute in a clean environment and enhance auto-cd behavior across different shell types.
- Filter out
WTP_SHELL_INTEGRATIONenvironment variable from hook execution to prevent state leakage - Improve worktree name detection logic to properly handle
-b/--branchoptions for auto-cd functionality - Rename variables from
branch_nametoworktree_namefor better code clarity
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/hooks/executor.go | Adds environment variable filtering to remove WTP_SHELL_INTEGRATION from hook execution |
| cmd/wtp/completion.go | Enhances shell integration with improved worktree name extraction logic for bash, zsh, and fish |
Comments suppressed due to low confidence (1)
internal/hooks/executor.go:130
- The variable name 'e' is ambiguous and conflicts with the receiver variable 'e *Executor'. Consider renaming to 'envVar' or 'envEntry' for clarity.
for _, e := range env {
Summary
wtp addcommandsChanges
1. Environment Variable Filtering in Hooks
WTP_SHELL_INTEGRATIONfrom hook execution environment2. Auto-CD Functionality Improvements
-b/--branchoptionswtp add3. Code Clarity Improvements
branch_namevariables toworktree_namefor accuracyTest plan
-boptionwtp addscenarios🤖 Generated with Claude Code
Summary by CodeRabbit
wtp addcommand across bash, zsh, and fish by improving how the target worktree name is determined from command-line arguments.