(index: Partial<StructuredPatch>)
| 412 | // Parses the --- and +++ headers, if none are found, no lines |
| 413 | // are consumed. |
| 414 | function parseFileHeader(index: Partial<StructuredPatch>) { |
| 415 | const fileHeaderMatch = (/^(---|\+\+\+)\s+/).exec(diffstr[i]); |
| 416 | if (fileHeaderMatch) { |
| 417 | const prefix = fileHeaderMatch[1], |
| 418 | data = diffstr[i].substring(3).trim().split('\t', 2), |
| 419 | header = (data[1] || '').trim(); |
| 420 | let fileName = data[0]; |
| 421 | if (fileName.startsWith('"')) { |
| 422 | fileName = unquoteIfQuoted(fileName); |
| 423 | } else { |
| 424 | fileName = fileName.replace(/\\\\/g, '\\'); |
| 425 | } |
| 426 | if (prefix === '---') { |
| 427 | index.oldFileName = fileName; |
| 428 | index.oldHeader = header; |
| 429 | } else { |
| 430 | index.newFileName = fileName; |
| 431 | index.newHeader = header; |
| 432 | } |
| 433 | |
| 434 | i++; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | // Parses a hunk |
| 439 | // This assumes that we are at the start of a hunk. |
no test coverage detected