* Parse git diff --numstat output to get file info with binary detection * Format: "10\t5\tfile.ts" for text files, "-\t-\tfile.png" for binary files
(output: string)
| 938 | * Format: "10\t5\tfile.ts" for text files, "-\t-\tfile.png" for binary files |
| 939 | */ |
| 940 | function parseNumstatOutput(output: string): GitFileInfo[] { |
| 941 | if (!output.trim()) return [] |
| 942 | |
| 943 | return output |
| 944 | .split("\n") |
| 945 | .filter((line) => line.trim()) |
| 946 | .map((line) => { |
| 947 | // Format: additions<tab>deletions<tab>filepath |
| 948 | // Binary files show as: -<tab>-<tab>filepath |
| 949 | const parts = line.split("\t") |
| 950 | if (parts.length < 3) return null |
| 951 | |
| 952 | const [additions, , ...pathParts] = parts |
| 953 | const filePath = pathParts.join("\t") // Handle paths with tabs (rare but possible) |
| 954 | const binary = additions === "-" |
| 955 | |
| 956 | return { path: filePath, binary } |
| 957 | }) |
| 958 | .filter((f): f is GitFileInfo => f !== null) |
| 959 | } |
| 960 | |
| 961 | /** Merge status codes from --name-status into GitFileInfo[] from --numstat */ |
| 962 | function mergeFileStatuses(files: GitFileInfo[], statuses: ChangedFileInfo[]): void { |
no outgoing calls
no test coverage detected