Commit 6e413f8
fix(utils): address CodeRabbit review feedback on git-bash discovery
Three improvements suggested by CodeRabbit's PR review:
1. Use path.win32 for processing `where.exe` results (MAJOR). On POSIX
hosts, `path.resolve('C:\\foo')` treats backslashes as literal
characters and produces a wrong (relative) result, which would let
cwd shadowing slip past the security check. Switch to `path.win32.*`
so the cwd filtering evaluates `where.exe`'s Windows-style paths
with Windows semantics regardless of host OS.
Also switched the cwd check from `startsWith` to `path.win32.relative`,
which is more robust: returns `''` for cwd itself, `..`/`../...` for
outside, and a non-absolute path for inside. Avoids edge cases with
trailing separators and mixed case.
2. Inject `USERPROFILE` through `GitBashDiscoveryDeps` (NITPICK). The
Scoop fallback in `searchDefaultBashLocations` was reading
`process.env.USERPROFILE` directly, breaking hermetic testing of
that branch. Threaded through as an optional deps field, defaults
to `process.env.USERPROFILE` for production.
3. Add `envOverride: ''` to the manual `GitBashDiscoveryDeps` fixture
in the "skips where.exe git when bash is already found via PATH"
test (INLINE). Without this, the test would pass for the wrong
reason (env override) on developer machines that have
`CLAUDE_CODE_GIT_BASH_PATH` set, instead of exercising the PATH
short-circuit behavior the test is named after.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 7766597 commit 6e413f8
2 files changed
Lines changed: 39 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
290 | 294 | | |
291 | 295 | | |
292 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| 68 | + | |
60 | 69 | | |
61 | 70 | | |
62 | 71 | | |
| |||
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
69 | | - | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
117 | | - | |
118 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
119 | 137 | | |
120 | 138 | | |
121 | 139 | | |
122 | | - | |
123 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
124 | 148 | | |
125 | | - | |
126 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
127 | 154 | | |
128 | 155 | | |
129 | 156 | | |
| |||
188 | 215 | | |
189 | 216 | | |
190 | 217 | | |
191 | | - | |
| 218 | + | |
192 | 219 | | |
193 | 220 | | |
194 | 221 | | |
| |||
0 commit comments