(stdout: string)
| 81 | * we treat as 0. Returns the aggregate across all files. |
| 82 | */ |
| 83 | export function parseNumstat(stdout: string): { |
| 84 | additions: number; |
| 85 | deletions: number; |
| 86 | } { |
| 87 | let additions = 0; |
| 88 | let deletions = 0; |
| 89 | for (const line of stdout.split('\n')) { |
| 90 | if (line.length === 0) continue; |
| 91 | const [addedText, deletedText] = line.split('\t'); |
| 92 | additions += parseNumstatCount(addedText); |
| 93 | deletions += parseNumstatCount(deletedText); |
| 94 | } |
| 95 | return { additions, deletions }; |
| 96 | } |
| 97 | |
| 98 | function parseNumstatCount(value: string | undefined): number { |
| 99 | if (value === undefined || value === '-') return 0; |
no test coverage detected