Ignore nested reference paths
- SHA
81934c30ac494d019427a6abdb8039214de6be74- Parents
-
3719f44 - Tree
a85dad9
81934c3
81934c30ac494d019427a6abdb8039214de6be743719f44
a85dad9| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/runtime/dod.py
|
8 | 2 |
| M |
tests/test_dod.py
|
33 | 0 |
src/loader/runtime/dod.pymodified@@ -1093,13 +1093,19 @@ def _extract_file_change_path_literals(lines: list[str]) -> list[str]: | ||
| 1093 | 1093 | paths: list[str] = [] |
| 1094 | 1094 | seen: set[str] = set() |
| 1095 | 1095 | directory_stack: list[tuple[int, str]] = [] |
| 1096 | + read_only_stack: list[int] = [] | |
| 1096 | 1097 | |
| 1097 | 1098 | for line in lines: |
| 1098 | - if _line_describes_read_only_file_change(line): | |
| 1099 | - continue | |
| 1100 | 1099 | indent = len(line) - len(line.lstrip(" ")) |
| 1100 | + while read_only_stack and indent <= read_only_stack[-1]: | |
| 1101 | + read_only_stack.pop() | |
| 1101 | 1102 | while directory_stack and indent <= directory_stack[-1][0]: |
| 1102 | 1103 | directory_stack.pop() |
| 1104 | + if _line_describes_read_only_file_change(line): | |
| 1105 | + read_only_stack.append(indent) | |
| 1106 | + continue | |
| 1107 | + if read_only_stack: | |
| 1108 | + continue | |
| 1103 | 1109 | |
| 1104 | 1110 | backticked = re.findall(r"`([^`]+)`", line) |
| 1105 | 1111 | if backticked: |
tests/test_dod.pymodified@@ -398,6 +398,39 @@ def test_collect_planned_artifact_targets_ignores_read_only_reference_paths( | ||
| 398 | 398 | ] |
| 399 | 399 | |
| 400 | 400 | |
| 401 | +def test_collect_planned_artifact_targets_ignores_nested_read_only_reference_paths( | |
| 402 | + tmp_path: Path, | |
| 403 | +) -> None: | |
| 404 | + implementation_plan = tmp_path / "implementation.md" | |
| 405 | + implementation_plan.write_text( | |
| 406 | + "\n".join( | |
| 407 | + [ | |
| 408 | + "# Implementation Plan", | |
| 409 | + "", | |
| 410 | + "## File Changes", | |
| 411 | + "1. Create directory structure for nginx guide:", | |
| 412 | + f" - `{tmp_path / 'Loader' / 'guides' / 'nginx' / 'index.html'}`", | |
| 413 | + f" - `{tmp_path / 'Loader' / 'guides' / 'nginx' / 'chapters'}/`", | |
| 414 | + "2. Analyze existing fortran guide structure to understand the format:", | |
| 415 | + " - `~/Loader/guides/fortran/`", | |
| 416 | + " - `~/Loader/guides/fortran/chapters/`", | |
| 417 | + "3. Create nginx guide content following the same structure and cadence as the fortran guide", | |
| 418 | + "", | |
| 419 | + ] | |
| 420 | + ) | |
| 421 | + ) | |
| 422 | + | |
| 423 | + dod = create_definition_of_done("Create an nginx guide from a Fortran reference.") | |
| 424 | + dod.implementation_plan = str(implementation_plan) | |
| 425 | + | |
| 426 | + targets = collect_planned_artifact_targets(dod, project_root=tmp_path) | |
| 427 | + | |
| 428 | + assert targets == [ | |
| 429 | + (tmp_path / "Loader" / "guides" / "nginx" / "index.html", False), | |
| 430 | + (tmp_path / "Loader" / "guides" / "nginx" / "chapters", True), | |
| 431 | + ] | |
| 432 | + | |
| 433 | + | |
| 401 | 434 | def test_all_planned_artifacts_exist_requires_file_contents_for_planned_output_directory( |
| 402 | 435 | tmp_path: Path, |
| 403 | 436 | ) -> None: |