( original: string, modified: string, )
| 43 | } |
| 44 | |
| 45 | function countTextDiffStats( |
| 46 | original: string, |
| 47 | modified: string, |
| 48 | ): GitDiffLineStats { |
| 49 | const originalLines = original.length === 0 ? [] : original.split("\n"); |
| 50 | const modifiedLines = modified.length === 0 ? [] : modified.split("\n"); |
| 51 | |
| 52 | if (originalLines.length === 0) { |
| 53 | return { additions: modifiedLines.length, deletions: 0 }; |
| 54 | } |
| 55 | |
| 56 | if (modifiedLines.length === 0) { |
| 57 | return { additions: 0, deletions: originalLines.length }; |
| 58 | } |
| 59 | |
| 60 | const unchanged = countUnchangedLines(originalLines, modifiedLines); |
| 61 | return { |
| 62 | additions: modifiedLines.length - unchanged, |
| 63 | deletions: originalLines.length - unchanged, |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Work budget for the exact count in {@link countUnchangedLines}. Ordinary |
no test coverage detected