(rawPatch: string)
| 2 | import type { DiffFile, DiffFileStatus } from '../types'; |
| 3 | |
| 4 | function splitDiffChunks(rawPatch: string): string[] { |
| 5 | const matches = [...rawPatch.matchAll(/^diff --git /gm)]; |
| 6 | if (matches.length === 0) return []; |
| 7 | |
| 8 | return matches.map((match, index) => { |
| 9 | const start = match.index ?? 0; |
| 10 | const end = matches[index + 1]?.index ?? rawPatch.length; |
| 11 | return rawPatch.slice(start, end); |
| 12 | }); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Change type from the chunk's git metadata lines. Scans only the extended |