Skip to content

Commit ca5dd17

Browse files
committed
fix(workspace): retain anchored source header compatibility
1 parent 8d0aced commit ca5dd17

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/work-bundle/control_plane.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def _v3_repositories(text: str) -> list[dict[str, object]]:
411411

412412
def _source_repository_bounds(lines: list[str]) -> tuple[int, int] | None:
413413
start = next((i for i, line in enumerate(lines)
414-
if re.fullmatch(r"source_repositories:\s*(?:#.*)?", line.rstrip())), None)
414+
if re.match(r"^source_repositories:(?:\s|$)", line)), None)
415415
if start is None:
416416
return None
417417
# Any non-comment root content ends the list, including quoted keys and

tests/test_multi_repository_member.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def test_multi_member_add_only_and_collisions(multi, tmp_path):
202202

203203

204204
@pytest.mark.parametrize("mode", ["single", "multi"])
205-
@pytest.mark.parametrize("shape", ["commented-header", "quoted-key", "quoted-nested", "commented-control", "owner-flow", "owner-comment"])
205+
@pytest.mark.parametrize("shape", ["commented-header", "anchored-header", "quoted-key", "quoted-nested", "commented-control", "owner-flow", "owner-comment"])
206206
@pytest.mark.parametrize("dependency_free", [False, True])
207207
def test_member_add_preserves_yaml_section_boundaries(multi, tmp_path, monkeypatch, mode, shape, dependency_free):
208208
config, workspace, remote = multi
@@ -212,6 +212,8 @@ def test_member_add_preserves_yaml_section_boundaries(multi, tmp_path, monkeypat
212212
text = metadata.read_text()
213213
if shape == "commented-header":
214214
text = text.replace("source_repositories:", "source_repositories: # managed members")
215+
elif shape == "anchored-header":
216+
text = text.replace("source_repositories:", "source_repositories: &sources")
215217
elif shape == "quoted-key":
216218
text = text.replace("prefer_subagent:", "'custom_owner_field': retained\nprefer_subagent:")
217219
elif shape == "quoted-nested":
@@ -245,6 +247,8 @@ def test_member_add_preserves_yaml_section_boundaries(multi, tmp_path, monkeypat
245247
assert document["custom_owner_field"] == "retained"
246248
elif shape == "commented-header":
247249
assert "source_repositories: # managed members" in metadata.read_text()
250+
elif shape == "anchored-header":
251+
assert "source_repositories: &sources" in metadata.read_text()
248252
elif shape == "commented-control":
249253
assert "control_plane: # portable settings" in metadata.read_text()
250254
elif shape == "owner-comment":

0 commit comments

Comments
 (0)