| 86 | } |
| 87 | |
| 88 | function parseAdd(lines: ReadonlyArray<string>, start: number) { |
| 89 | const content: string[] = [] |
| 90 | let index = start |
| 91 | while (index < lines.length && !lines[index]!.startsWith("***")) { |
| 92 | if (!lines[index]!.startsWith("+")) throw new Error(`Invalid add file line: ${lines[index]}`) |
| 93 | content.push(lines[index]!.slice(1)) |
| 94 | index++ |
| 95 | } |
| 96 | return { content: content.join("\n"), next: index } |
| 97 | } |
| 98 | |
| 99 | function parseUpdate(lines: ReadonlyArray<string>, start: number) { |
| 100 | const chunks: UpdateFileChunk[] = [] |