surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | '-c', |
| 14 | 14 | 'core.quotePath=false', |
| 15 | 15 | 'diff', |
| 16 | + '--no-color', | |
| 16 | 17 | '--no-ext-diff', |
| 17 | 18 | '--no-textconv', |
| 18 | 19 | '--ignore-submodules=dirty', |
| @@ -148,6 +148,42 @@ | ||
| 148 | 148 | ).toBe(true) |
| 149 | 149 | }) |
| 150 | 150 | |
| 151 | + test("forced git colors do not hide a changed file's hunks", async () => { | |
| 152 | + const deps = depsOf({ | |
| 153 | + 'HEAD --shortstat': Fixtures.ok( | |
| 154 | + ' 1 file changed, 1 insertion(+), 1 deletion(-)', | |
| 155 | + ), | |
| 156 | + 'HEAD --numstat': Fixtures.ok('1\t1\ta.ts\0'), | |
| 157 | + 'ls-files': Fixtures.ok(), | |
| 158 | + }) | |
| 159 | + | |
| 160 | + const git = Fixtures.scriptedGitOf({ | |
| 161 | + '--no-color': Fixtures.ok('@@ -1 +1 @@\n-old\n+new\n'), | |
| 162 | + diff: Fixtures.ok( | |
| 163 | + '\x1b[36m@@ -1 +1 @@\x1b[m\n\x1b[31m-old\x1b[m\n' + | |
| 164 | + '\x1b[32m+\x1b[m\x1b[32mnew\x1b[m\n', | |
| 165 | + ), | |
| 166 | + }) | |
| 167 | + | |
| 168 | + const outcome = await Git.fetchDiff(deps, 'uncommitted') | |
| 169 | + const data = outcome.kind === 'data' ? outcome.data : null | |
| 170 | + const [row] = data?.files ?? [] | |
| 171 | + | |
| 172 | + expect(data?.stats).toEqual({ | |
| 173 | + filesCount: 1, | |
| 174 | + linesAdded: 1, | |
| 175 | + linesRemoved: 1, | |
| 176 | + }) | |
| 177 | + | |
| 178 | + expect( | |
| 179 | + data && row ? await Git.fetchFileHunks(git.run, data, row) : null, | |
| 180 | + ).toEqual({ | |
| 181 | + hunks: [{ oldStart: 1, newStart: 1, lines: ['-old', '+new'] }], | |
| 182 | + isTruncated: false, | |
| 183 | + isLarge: false, | |
| 184 | + }) | |
| 185 | + }) | |
| 186 | + | |
| 151 | 187 | test('uncommitted mode drops pre-session untracked files', async () => { |
| 152 | 188 | const outcome = await Git.fetchDiff( |
| 153 | 189 | depsOf( |