(file: string)
| 412 | } |
| 413 | |
| 414 | export function parsePatchFile(file: string): ParsedPatchFile { |
| 415 | const lines = file.split(/\n/g) |
| 416 | if (lines[lines.length - 1] === "") { |
| 417 | lines.pop() |
| 418 | } |
| 419 | try { |
| 420 | return interpretParsedPatchFile( |
| 421 | parsePatchLines(lines, { supportLegacyDiffs: false }), |
| 422 | ) |
| 423 | } catch (e) { |
| 424 | if ( |
| 425 | e instanceof Error && |
| 426 | e.message === "hunk header integrity check failed" |
| 427 | ) { |
| 428 | return interpretParsedPatchFile( |
| 429 | parsePatchLines(lines, { supportLegacyDiffs: true }), |
| 430 | ) |
| 431 | } |
| 432 | throw e |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | export function verifyHunkIntegrity(hunk: Hunk) { |
| 437 | // verify hunk integrity |
no test coverage detected
searching dependent graphs…