Parses the content (+) lines for an Add File action.
(self, lines: List[str], index: int)
| 514 | return action, index, total_fuzz |
| 515 | |
| 516 | def _parse_add_file_content(self, lines: List[str], index: int) -> Tuple[PatchAction, int]: |
| 517 | """Parses the content (+) lines for an Add File action.""" |
| 518 | added_lines: List[str] = [] |
| 519 | while index < len(lines): |
| 520 | line = lines[index] |
| 521 | norm_line = _norm(line) |
| 522 | # Stop if we hit another action or end marker |
| 523 | if norm_line.startswith( |
| 524 | ( |
| 525 | "*** End Patch", |
| 526 | "*** Update File:", |
| 527 | "*** Delete File:", |
| 528 | "*** Add File:", |
| 529 | ) |
| 530 | ): |
| 531 | break |
| 532 | |
| 533 | # Expect lines to start with '+' |
| 534 | if not line.startswith("+"): |
| 535 | # Tolerate blank lines? Or require '+'? Reference implies '+' required. |
| 536 | if norm_line.strip() == "": |
| 537 | # Treat blank line as adding a blank line |
| 538 | added_lines.append("") |
| 539 | else: |
| 540 | raise DiffError(f"Invalid Add File line (missing '+'): {line}") |
| 541 | else: |
| 542 | added_lines.append(line[1:]) # Strip leading '+' |
| 543 | |
| 544 | index += 1 |
| 545 | |
| 546 | action = PatchAction(type=ActionType.ADD, path="", new_content="\n".join(added_lines)) |
| 547 | return action, index |
| 548 | |
| 549 | def apply_edits(self, edits: List[PatchAction]): |
| 550 | """ |
no test coverage detected