Commit 8d4c5c6
fix: handle file paths with spaces in git commands (#156)
* Initial plan
* chore: initial investigation of path with spaces issue
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
* fix: handle file paths with spaces in git commands
- Add array-based overloads to ICliWrap interface
- Implement array-based ExecAsync and ExecBufferedAsync in HuskyCliWrap
- Update IGit interface with array-based overloads
- Update Git service to support array arguments
- Fix StagedTask.ReStageFiles to pass file paths as separate arguments
- Remove platform-specific quoting logic (now handled by CliWrap)
- Fix hash-object and update-index commands to use array arguments
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
* fix: remove quotes from verbose logging to match actual execution
Update logging in ReStageFiles to display file paths without quotes,
matching how they are actually passed to git commands.
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
* fix: remove test tasks from task-runner.json to avoid cross-platform issues
Removed the Windows-specific test tasks ('echo staged files' and 'root-dir' variable)
that were causing failures on Linux CI. These tasks used 'cmd' which is not available
on Unix systems. The core fix for path handling with spaces remains intact in the
production code.
* test: add comprehensive tests for path handling with spaces
Added unit tests:
- Test for GetStagedFiles with paths containing spaces
- Test for ExecAsync with array arguments
- Test for ExecBufferedAsync with array arguments
Added integration tests in PathWithSpacesTests.cs:
- Test with single spaces in path
- Test with multiple consecutive spaces
- Test with parentheses and spaces
- Test with mixed special characters
- Test with complex nested directory structure
- Test with multiple files with spaces
- Test with relative path mode
All tests verify that paths with spaces are properly handled without
"fatal: pathspec" errors.
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
* refactor: restore test config with cross-platform commands and use collection expressions
- Restore test variable and task in task-runner.json
- Make test commands cross-platform: use bash/echo instead of cmd
- Update StagedTask to use C# 12 collection expression syntax
- Replace `new List<string> { "add" }; gitAddArgs.AddRange(stagedFiles)` with `["add", ..stagedFiles]`
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
* refactor: improve test config consistency
- Change root-dir variable to use 'pwd' instead of 'ls' to match its purpose
- Rename task to 'echo-staged-files' for consistency with kebab-case naming
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alirezanet <7004080+alirezanet@users.noreply.github.com>1 parent a51fed5 commit 8d4c5c6
9 files changed
Lines changed: 393 additions & 10 deletions
File tree
- .husky
- src/Husky
- Services
- Contracts
- TaskRunner
- tests
- HuskyIntegrationTests
- HuskyTest/Services
File mode changed.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
193 | 203 | | |
194 | 204 | | |
195 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
29 | 46 | | |
30 | 47 | | |
31 | 48 | | |
| |||
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
56 | 85 | | |
57 | 86 | | |
58 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
| 109 | + | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
125 | | - | |
| 124 | + | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| |||
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
146 | | - | |
| 145 | + | |
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
153 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| |||
0 commit comments