Merge reviewed contributor PR #3509 for incoming stewardship

This commit is contained in:
haelyra committed 2026-10-11 06:17:51 -04:00
commit 63b84217e3
2 files changed
+18 -1

No files matched your search

@@ -525,7 +525,7 @@ def parse_instinct_file(content: str) -> list[dict]:
in_frontmatter = False
content_lines = []
for line in content.split('\n'):
for line in content.removeprefix('\ufeff').split('\n'):
if line.strip() == '---':
if in_frontmatter:
# End of frontmatter - content comes next
@@ -208,6 +208,23 @@ Prevents vulnerabilities.
assert "Prevents vulnerabilities." in result[0]["content"]
@pytest.mark.parametrize("newline", ["\n", "\r\n"])
def test_parse_initial_utf8_bom(newline):
content = SAMPLE_INSTINCT_YAML.replace("\n", newline)
assert parse_instinct_file("\ufeff" + content) == parse_instinct_file(content)
def test_parse_preserves_bom_inside_content():
content = SAMPLE_INSTINCT_YAML.replace("Always write", "Always \ufeffwrite")
assert "Always \ufeffwrite" in parse_instinct_file(content)[0]["content"]
def test_load_instinct_file_with_utf8_bom(tmp_path):
(tmp_path / "bom.yaml").write_text(SAMPLE_INSTINCT_YAML, encoding="utf-8-sig")
instincts = _load_instincts_from_dir(tmp_path, "personal", "project")
assert [instinct["id"] for instinct in instincts] == ["test-instinct"]
def test_empty_content_no_error():
content = """\
---