| 90 | |
| 91 | function parseNameStatus(output: string): ChangeEntry[] { |
| 92 | if (!output.trim()) return []; |
| 93 | return output |
| 94 | .trim() |
| 95 | .split('\n') |
| 96 | .map((line) => { |
| 97 | // Format: "M\tpath" or "R100\told\tnew" |
| 98 | const parts = line.split('\t'); |
| 99 | if (parts.length < 2) return null; |
| 100 | const rawStatus = parts[0]!; |
| 101 | // Normalize rename status (R100 -> R) |
| 102 | const status = rawStatus.startsWith('R') ? 'R' : rawStatus; |
| 103 | const filePath = parts.length >= 3 ? parts[2]! : parts[1]!; |
| 104 | return { status, path: filePath }; |
| 105 | }) |
| 106 | .filter((entry): entry is ChangeEntry => entry !== null); |
| 107 | } |
| 108 | |
| 109 | /** Parse `git diff --numstat` output into a path → {additions, deletions} map. */ |
| 110 | function parseNumstat(output: string): Map<string, { additions: number; deletions: number }> { |
| 111 | const map = new Map<string, { additions: number; deletions: number }>(); |