| 25 | // (Bugbot PR #109 round-1 MEDIUM; reader/writer drift flagged on PR #555). |
| 26 | |
| 27 | function runGit(args, cwd) { |
| 28 | // Argv-array form, no shell. Avoids POSIX `2>/dev/null` redirects that |
| 29 | // break on Windows cmd.exe (#537). Failures (e.g. no HEAD~1 in a fresh |
| 30 | // repo) are surfaced as a non-zero status; callers distinguish them |
| 31 | // from successful empty output via the `ok` flag (PR #94 round-6 LOW). |
| 32 | const res = spawnSync('git', args, { |
| 33 | cwd, |
| 34 | encoding: 'utf8', |
| 35 | timeout: 5000, |
| 36 | maxBuffer: MAX_EXEC_BUFFER, |
| 37 | stdio: ['ignore', 'pipe', 'pipe'], |
| 38 | shell: false, |
| 39 | windowsHide: true, |
| 40 | }); |
| 41 | if (res.status === 0 && typeof res.stdout === 'string') { |
| 42 | return { ok: true, out: res.stdout.trim() }; |
| 43 | } |
| 44 | return { ok: false, out: '' }; |
| 45 | } |
| 46 | |
| 47 | function getGitDiffStats() { |
| 48 | // Use the host-provided workspace root, not process.cwd(): Cursor runs some |