Add Windows support for Git Bash and PowerShell#61
Add Windows support for Git Bash and PowerShell#61thoraxe wants to merge 1 commit intosatococoa:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds Windows support across CI and goreleaser, introduces PowerShell (pwsh) completion/hook and shell-init support, normalizes and resolves paths before relativity checks, updates tests for cross-platform behavior, and documents Windows installation and setup. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Shell as PowerShell
participant WTP as wtp CLI
participant Completion as ShellCompletion
User->>WTP: run `wtp hook pwsh` (or `wtp shell-init pwsh`)
WTP->>WTP: generate PowerShell hook script / completion block
WTP->>Shell: output hook script to stdout
Shell->>Completion: register `Register-ArgumentCompleter` using `wtp` command name
Completion-->>Shell: completion registered
Shell-->>User: shell hook active, completions available
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
"it worked on my machine"... |
|
I just force pushed a fix for a number of things --
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
cmd/wtp/hook.go (1)
171-227: PowerShell hook implementation is solid with minor suggestions.The PowerShell hook correctly:
- Stores
$__wtpPathto prevent recursion- Checks for
--generate-shell-completionflag- Implements
cdfunctionality matching other shellsHowever, the executable discovery (lines 176-194) searches PATH then falls back to the current directory. While this works for testing, users who install wtp to a custom location outside PATH and without running from the install directory may encounter issues.
Consider documenting this discovery behavior in the PowerShell setup section of the README, or add a warning when
$__wtpPathis not found:function wtp { if (-not $__wtpPath) { - Write-Error "wtp executable not found. Please ensure wtp is in your PATH or current directory." + Write-Error "wtp executable not found. Please ensure wtp is in your PATH or current directory. Run 'Get-Command wtp' to verify installation." return 1 }README.md (1)
315-322: Clarify the WarningPreference workaround.The PowerShell setup silences warnings with
$WarningPreference = 'SilentlyContinue'. While this prevents noise, it might hide legitimate warnings from the shell-init script.Consider adding a brief explanation of why this is needed, or investigate if the underlying warnings can be fixed:
**PowerShell:** Add to your PowerShell profile (`$PROFILE` - typically `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1` or `~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`): ```powershell # Add wtp shell integration (completion + cd functionality) +# Note: Suppress warnings during initialization to avoid PowerShell module loading messages $WarningPreference = 'SilentlyContinue' Invoke-Expression -Command (& wtp shell-init pwsh | Out-String) $WarningPreference = 'Continue'</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: CodeRabbit UI **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between ffd7a2bc5e0b442da6e1dfc3e0eaddd471ad0c2c and 5c6f136f726e00df5bb01509276c35c164338fbe. </details> <details> <summary>📒 Files selected for processing (11)</summary> * `.github/workflows/ci.yml` (2 hunks) * `.goreleaser.yml` (2 hunks) * `README.md` (3 hunks) * `cmd/wtp/add_test.go` (6 hunks) * `cmd/wtp/cd_test.go` (2 hunks) * `cmd/wtp/completion_config.go` (2 hunks) * `cmd/wtp/hook.go` (4 hunks) * `cmd/wtp/list_test.go` (3 hunks) * `cmd/wtp/shell_init.go` (4 hunks) * `cmd/wtp/testhelpers_test.go` (1 hunks) * `cmd/wtp/worktree_managed.go` (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (4)</summary> * cmd/wtp/testhelpers_test.go * cmd/wtp/completion_config.go * .github/workflows/ci.yml * .goreleaser.yml </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>📓 Path-based instructions (2)</summary> <details> <summary>**/*.go</summary> **📄 CodeRabbit inference engine (AGENTS.md)** > `**/*.go`: Follow standard Go style with tabs and gofmt; package names must be short and lowercase > Keep import groups tidy; use goimports for organization with local prefix following module path `github.com/satococoa/wtp/v2` > Adhere to linting rules in `.golangci.yml` (vet, staticcheck, gosec, mnd, lll=120) > Wrap errors with context; avoid ignoring errors in Go code > Use snake_case for Go filenames (e.g., `remove.go`, `shell_integration.go`) > Document exported items in Go when non-trivial; follow godoc conventions Files: - `cmd/wtp/worktree_managed.go` - `cmd/wtp/shell_init.go` - `cmd/wtp/list_test.go` - `cmd/wtp/cd_test.go` - `cmd/wtp/add_test.go` - `cmd/wtp/hook.go` </details> <details> <summary>**/*_test.go</summary> **📄 CodeRabbit inference engine (AGENTS.md)** > `**/*_test.go`: Unit tests must be placed alongside packages as `*_test.go` files in the same directory > Target 70% code coverage with unit tests focusing on fast feedback and mocked git interactions using table-driven test cases Files: - `cmd/wtp/list_test.go` - `cmd/wtp/cd_test.go` - `cmd/wtp/add_test.go` </details> </details><details> <summary>🧠 Learnings (14)</summary> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Update README and CLI help text when user-facing behavior changes**Applied to files:** - `README.md` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Usego run ./cmd/wtp <args>for rapid feedback during development instead of building binaries**Applied to files:** - `README.md` - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: CLI entrypoint is located atcmd/wtp; new command implementations must integrate with the main CLI structure**Applied to files:** - `README.md` - `cmd/wtp/shell_init.go` - `cmd/wtp/list_test.go` - `cmd/wtp/cd_test.go` - `cmd/wtp/add_test.go` - `cmd/wtp/hook.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Shell integration must separate completion and hooks for clarity;wtp cdoutputs absolute worktree path with no side effects**Applied to files:** - `README.md` - `cmd/wtp/worktree_managed.go` - `cmd/wtp/shell_init.go` - `cmd/wtp/cd_test.go` - `cmd/wtp/hook.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Toggle shell integration paths withWTP_SHELL_INTEGRATION=1when testing cd behavior**Applied to files:** - `README.md` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Run commands from inside a worktree to mimic real usage (e.g.,go run ../cmd/wtp add feature/new-feature)**Applied to files:** - `README.md` - `cmd/wtp/worktree_managed.go` - `cmd/wtp/shell_init.go` - `cmd/wtp/list_test.go` - `cmd/wtp/cd_test.go` - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*.go : Keep import groups tidy; use goimports for organization with local prefix following module pathgithub.com/satococoa/wtp/v2**Applied to files:** - `cmd/wtp/worktree_managed.go` - `cmd/wtp/list_test.go` - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*_test.go : Target 70% code coverage with unit tests focusing on fast feedback and mocked git interactions using table-driven test cases**Applied to files:** - `cmd/wtp/list_test.go` - `cmd/wtp/cd_test.go` - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: The root module isgithub.com/satococoa/wtp/v2running on Go 1.24; maintain module path consistency**Applied to files:** - `cmd/wtp/list_test.go` - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*.go : Wrap errors with context; avoid ignoring errors in Go code**Applied to files:** - `cmd/wtp/list_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to test/e2e/**/*.go : End-to-end tests must be placed intest/e2eand exercise real git workflows using the built binary**Applied to files:** - `cmd/wtp/cd_test.go` - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*_test.go : Unit tests must be placed alongside packages as*_test.gofiles in the same directory**Applied to files:** - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Rungo tool task devbefore committing to ensure code is formatted, linted, and tests pass**Applied to files:** - `cmd/wtp/add_test.go` </details> <details> <summary>📚 Learning: 2025-12-02T13:33:48.693Z</summary>Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to .wtp.yml : Project hooks must be defined in.wtp.yml; keep commands deterministic and safe, avoiding destructive steps by default**Applied to files:** - `cmd/wtp/hook.go` </details> </details><details> <summary>🧬 Code graph analysis (4)</summary> <details> <summary>cmd/wtp/worktree_managed.go (2)</summary><blockquote> <details> <summary>internal/git/repository_integration_test.go (1)</summary> * `TestGetMainWorktreePath` (11-32) </details> <details> <summary>internal/config/config.go (1)</summary> * `c` (167-173) </details> </blockquote></details> <details> <summary>cmd/wtp/shell_init.go (2)</summary><blockquote> <details> <summary>cmd/wtp/shell_init_test.go (2)</summary> * `TestNewShellInitCommand` (12-32) * `TestShellInitCommand_OutputsValidScripts` (34-79) </details> <details> <summary>test/e2e/shell_test.go (1)</summary> * `TestShellEnvironment` (167-191) </details> </blockquote></details> <details> <summary>cmd/wtp/cd_test.go (1)</summary><blockquote> <details> <summary>internal/hooks/executor_test.go (1)</summary> * `TestExecutePostCreateHooks_Command` (103-140) </details> </blockquote></details> <details> <summary>cmd/wtp/hook.go (1)</summary><blockquote> <details> <summary>internal/command/types.go (1)</summary> * `Command` (4-8) </details> </blockquote></details> </details> </details> <details> <summary>🔇 Additional comments (6)</summary><blockquote> <details> <summary>cmd/wtp/cd_test.go (1)</summary><blockquote> `20-22`: **Appropriate Windows guard for Unix-specific paths.** The test skip is correct—this test uses hardcoded Unix paths (`/Users/dev/project/main`) that won't work on Windows. </blockquote></details> <details> <summary>cmd/wtp/worktree_managed.go (1)</summary><blockquote> `29-51`: **Robust cross-platform path normalization.** The changes correctly handle Windows-specific path issues: - `filepath.Clean` normalizes Git's forward slashes to OS-native separators - `EvalSymlinks` resolves symlinks and Windows junction points with safe fallback - The approach is backward-compatible with Unix systems </blockquote></details> <details> <summary>cmd/wtp/add_test.go (1)</summary><blockquote> `286-288`: **Consistent Windows test guards across multiple test cases.** All five Windows guards correctly skip tests that use Unix-specific hardcoded paths. The TODO comments indicate these will be addressed in future work. Also applies to: 335-337, 477-479, 567-569, 762-764 </blockquote></details> <details> <summary>README.md (1)</summary><blockquote> `117-139`: **Comprehensive Windows installation instructions.** The installation steps for both PowerShell and Git Bash are clear and well-structured. </blockquote></details> <details> <summary>cmd/wtp/shell_init.go (1)</summary><blockquote> `67-72`: **PowerShell shell-init follows established patterns.** The implementation correctly mirrors bash/zsh/fish structure: outputs completion first, then the hook. Test coverage for PowerShell functionality in shell_init_test.go must be verified to confirm this implementation is fully tested. </blockquote></details> <details> <summary>cmd/wtp/list_test.go (1)</summary><blockquote> `681-683`: **Test skipping with TODO tracking is appropriate.** The Windows guard correctly skips this test that relies on Unix-specific path conventions, allowing the test suite to maintain appropriate coverage targets while acknowledging the platform limitation. The TODO comment provides inline tracking of this limitation. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
- Add Windows (amd64/arm64) to CI workflow and GoReleaser config - Fix shell detection and hook scripts for Git Bash and PowerShell - Fix path separator handling in worktree management (git returns forward slashes on Windows, Go uses backslashes) - Skip tests with hardcoded Unix paths on Windows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @cmd/wtp/hook.go:
- Around line 223-237: The PowerShell hook currently errors when running "wtp
cd" with no args; change the "cd" branch to allow optional argument: if $args[1]
is missing call & $__wtpPath cd with no operand, capture its output in
$targetDir if any, check $LASTEXITCODE and $targetDir, and only call
Set-Location when a valid directory is returned; otherwise fall back to invoking
& $__wtpPath cd $args[1] when an argument is present. Ensure you update the
usage check (remove the early Write-Error/return) and keep the existing
variables $__wtpPath, $args, $targetDir, $LASTEXITCODE and Set-Location logic
for success/fallback behavior.
🧹 Nitpick comments (1)
cmd/wtp/completion_config.go (1)
251-261: Consider verifying the replacement succeeded.The string replacement targets a specific multi-line pattern from the urfave/cli-generated completion script. If the library changes its PowerShell completion format in a future version, the replacement will silently fail (returning the unmodified script), which could break PowerShell completion in subtle ways.
♻️ Add validation to detect failed replacement
func patchPowerShellCompletionScript(script string) string { // Replace the dynamic command name detection with hardcoded "wtp" // The original script tries to get the name from $MyInvocation.MyCommand.Name // which doesn't work when invoked via Invoke-Expression target := "$fn = $($MyInvocation.MyCommand.Name)\n$name = $fn -replace \"(.*)\\.ps1$\", '$1'\nRegister-ArgumentCompleter -Native -CommandName $name -ScriptBlock {" replacement := "Register-ArgumentCompleter -Native -CommandName 'wtp' -ScriptBlock {" - script = strings.Replace(script, target, replacement, 1) + patched := strings.Replace(script, target, replacement, 1) + + // Verify replacement succeeded by checking for the expected result + if !strings.Contains(patched, replacement) { + // Log or handle the case where the pattern wasn't found + // For now, return the original script as fallback + return script + } - return script + return patched }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
.github/workflows/ci.yml.goreleaser.ymlREADME.mdcmd/wtp/add_test.gocmd/wtp/cd_test.gocmd/wtp/completion_config.gocmd/wtp/hook.gocmd/wtp/list_test.gocmd/wtp/shell_init.gocmd/wtp/testhelpers_test.gocmd/wtp/worktree_managed.go
🚧 Files skipped from review as they are similar to previous changes (6)
- cmd/wtp/cd_test.go
- cmd/wtp/list_test.go
- cmd/wtp/add_test.go
- README.md
- cmd/wtp/worktree_managed.go
- .goreleaser.yml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*.go: Follow standard Go style with tabs and gofmt; package names must be short and lowercase
Keep import groups tidy; use goimports for organization with local prefix following module pathgithub.com/satococoa/wtp/v2
Adhere to linting rules in.golangci.yml(vet, staticcheck, gosec, mnd, lll=120)
Wrap errors with context; avoid ignoring errors in Go code
Use snake_case for Go filenames (e.g.,remove.go,shell_integration.go)
Document exported items in Go when non-trivial; follow godoc conventions
Files:
cmd/wtp/completion_config.gocmd/wtp/hook.gocmd/wtp/testhelpers_test.gocmd/wtp/shell_init.go
**/*_test.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*_test.go: Unit tests must be placed alongside packages as*_test.gofiles in the same directory
Target 70% code coverage with unit tests focusing on fast feedback and mocked git interactions using table-driven test cases
Files:
cmd/wtp/testhelpers_test.go
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Shell integration must separate completion and hooks for clarity; `wtp cd` outputs absolute worktree path with no side effects
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: CLI entrypoint is located at `cmd/wtp`; new command implementations must integrate with the main CLI structure
Applied to files:
cmd/wtp/completion_config.go.github/workflows/ci.ymlcmd/wtp/hook.gocmd/wtp/testhelpers_test.gocmd/wtp/shell_init.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Shell integration must separate completion and hooks for clarity; `wtp cd` outputs absolute worktree path with no side effects
Applied to files:
cmd/wtp/completion_config.gocmd/wtp/hook.gocmd/wtp/shell_init.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Run `go tool task dev` before committing to ensure code is formatted, linted, and tests pass
Applied to files:
.github/workflows/ci.yml
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Use `go run ./cmd/wtp <args>` for rapid feedback during development instead of building binaries
Applied to files:
.github/workflows/ci.yml
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Run commands from inside a worktree to mimic real usage (e.g., `go run ../cmd/wtp add feature/new-feature`)
Applied to files:
.github/workflows/ci.ymlcmd/wtp/testhelpers_test.gocmd/wtp/shell_init.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to test/e2e/**/*.go : End-to-end tests must be placed in `test/e2e` and exercise real git workflows using the built binary
Applied to files:
.github/workflows/ci.ymlcmd/wtp/testhelpers_test.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: The root module is `github.com/satococoa/wtp/v2` running on Go 1.24; maintain module path consistency
Applied to files:
.github/workflows/ci.ymlcmd/wtp/testhelpers_test.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to .wtp.yml : Project hooks must be defined in `.wtp.yml`; keep commands deterministic and safe, avoiding destructive steps by default
Applied to files:
cmd/wtp/hook.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*_test.go : Target 70% code coverage with unit tests focusing on fast feedback and mocked git interactions using table-driven test cases
Applied to files:
cmd/wtp/testhelpers_test.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*_test.go : Unit tests must be placed alongside packages as `*_test.go` files in the same directory
Applied to files:
cmd/wtp/testhelpers_test.go
📚 Learning: 2025-12-02T13:33:48.693Z
Learnt from: CR
Repo: satococoa/wtp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-02T13:33:48.693Z
Learning: Applies to **/*.go : Keep import groups tidy; use goimports for organization with local prefix following module path `github.com/satococoa/wtp/v2`
Applied to files:
cmd/wtp/testhelpers_test.go
🧬 Code graph analysis (2)
cmd/wtp/testhelpers_test.go (1)
internal/config/config.go (2)
Config(13-17)Defaults(20-22)
cmd/wtp/shell_init.go (1)
internal/command/types.go (1)
Command(4-8)
🔇 Additional comments (14)
cmd/wtp/completion_config.go (1)
59-60: LGTM!The PowerShell case follows the established pattern for other shells.
.github/workflows/ci.yml (3)
15-15: LGTM!Adding Windows to the CI matrix ensures cross-platform compatibility.
22-26: LGTM!The Git configuration correctly handles line endings for Windows. Setting
core.autocrlf=falseandcore.eol=lfensures consistent line endings across platforms, which is standard practice for Go projects.
94-94: LGTM!The Windows build is now enabled. Note that while this step doesn't explicitly test the Windows binary with
--help(like the Linux binary on line 98-99), the test job already validates Windows functionality by running the full test suite on windows-latest.cmd/wtp/testhelpers_test.go (2)
58-58: LGTM!Using
filepath.Joininstead of hardcoded path separators ensures the test works correctly on Windows (which uses backslashes) and Unix systems (which use forward slashes).
67-67: LGTM!Using
filepath.Joinfor the relative path with..segments correctly handles platform-specific path separators.cmd/wtp/hook.go (4)
22-23: LGTM!The help text correctly includes PowerShell setup instructions alongside the other shells.
43-48: LGTM!The pwsh subcommand follows the established pattern for bash, zsh, and fish.
77-83: LGTM!The hookPowerShell handler follows the same pattern as the other shell handlers.
186-222: Good executable discovery strategy with proper recursion prevention.The hook correctly stores a reference to the actual wtp executable in
$__wtpPathand uses& $__wtpPathto invoke it, preventing infinite recursion. The PATH-first discovery with current directory fallback is reasonable.cmd/wtp/shell_init.go (4)
17-17: LGTM!Adding pwsh to the allowedShells map enables PowerShell support in the shell-init flow.
46-47: LGTM!The help text correctly documents PowerShell setup instructions.
67-72: LGTM!The pwsh subcommand definition follows the established pattern for bash, zsh, and fish.
134-151: LGTM!The shellInitPowerShell implementation correctly follows the established pattern: output completion first, then the hook, separated by a newline. This is consistent with the bash/zsh/fish handlers.
| if ($args[0] -eq "cd") { | ||
| if (-not $args[1]) { | ||
| Write-Error "Usage: wtp cd <worktree>" | ||
| return 1 | ||
| } | ||
| $targetDir = & $__wtpPath cd $args[1] 2>$null | ||
| if ($LASTEXITCODE -eq 0 -and $targetDir) { | ||
| Set-Location $targetDir | ||
| } else { | ||
| & $__wtpPath cd $args[1] | ||
| } | ||
| } else { | ||
| & $__wtpPath @args | ||
| } | ||
| }`) |
There was a problem hiding this comment.
PowerShell cd behavior is inconsistent with bash/zsh/fish.
The PowerShell version requires an argument to wtp cd (line 224-227 errors if $args[1] is missing), but the bash/zsh/fish hooks support wtp cd without arguments (see lines 96-99 for bash). This behavioral inconsistency could confuse users who expect the same functionality across shells.
🔧 Proposed fix to support argument-less cd
if ($args[0] -eq "cd") {
- if (-not $args[1]) {
- Write-Error "Usage: wtp cd <worktree>"
- return 1
- }
- $targetDir = & $__wtpPath cd $args[1] 2>$null
+ if (-not $args[1]) {
+ $targetDir = & $__wtpPath cd 2>$null
+ } else {
+ $targetDir = & $__wtpPath cd $args[1] 2>$null
+ }
if ($LASTEXITCODE -eq 0 -and $targetDir) {
Set-Location $targetDir
} else {
- & $__wtpPath cd $args[1]
+ if ($args[1]) {
+ & $__wtpPath cd $args[1]
+ } else {
+ & $__wtpPath cd
+ }
}
} else {🤖 Prompt for AI Agents
In @cmd/wtp/hook.go around lines 223 - 237, The PowerShell hook currently errors
when running "wtp cd" with no args; change the "cd" branch to allow optional
argument: if $args[1] is missing call & $__wtpPath cd with no operand, capture
its output in $targetDir if any, check $LASTEXITCODE and $targetDir, and only
call Set-Location when a valid directory is returned; otherwise fall back to
invoking & $__wtpPath cd $args[1] when an argument is present. Ensure you update
the usage check (remove the early Write-Error/return) and keep the existing
variables $__wtpPath, $args, $targetDir, $LASTEXITCODE and Set-Location logic
for success/fallback behavior.
|
I was going to work on PowerShell support but saw this PR was open - @thoraxe can you address the CI failures and code comment above? |
This commit enables comprehensive Windows support with both Git Bash and PowerShell shell integration, providing Windows users with the same seamless worktree management experience as macOS and Linux users.
Changes:
PowerShell Integration:
Git Bash Integration:
Testing:
🚀 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.