fix(ci): check the prompt-surface snapshot out with LF on every host
prompt_surface.py now writes the snapshot with LF on Windows and the
snapshot test compares bytes, but .gitattributes pinned only the .json
files. The prompts/*.txt files fell under "* text=auto", so a Windows clone
with core.autocrlf=true (the Git for Windows default) checked them out as
CRLF, and every prompt read as stale on a clean checkout.
Pin the whole snapshot directory to eol=lf. The new test checks that every
snapshot file resolves to eol=lf. On a core.autocrlf=true checkout of
2304f34aea, both it and test_committed_prompt_surface_is_current fail, with
all 9 prompts stale. With this .gitattributes the same checkout passes 3/3.
Found by the sol-loop review on #159146.
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -41,6 +41,9 @@ docker/entrypoint.sh text eol=lf
|
||||
*.svg text eol=lf
|
||||
*.ps1 text eol=crlf
|
||||
|
||||
# scripts/ci/prompt_surface.py renders this snapshot with LF on every host and compares bytes.
|
||||
tests/fixtures/prompt_surface/** text eol=lf
|
||||
|
||||
# Shims at old module paths: hermes_agent/compat/required_names.py
|
||||
# BEGIN shims (generated by scripts/move/generate_shims.py; do not edit)
|
||||
/tools/plugin_guard.py linguist-generated=true
|
||||
|
||||
@@ -13,6 +13,7 @@ from __future__ import annotations
|
||||
import filecmp
|
||||
import importlib.util
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
@@ -44,6 +45,15 @@ def test_committed_prompt_surface_is_current(tmp_path):
|
||||
)
|
||||
|
||||
|
||||
def test_snapshot_is_checked_out_with_the_lf_that_render_writes():
|
||||
"""render() writes LF on every host and the check above compares bytes, so a Windows clone with
|
||||
core.autocrlf=true must not check the committed snapshot out as CRLF."""
|
||||
files = "\n".join(p.relative_to(REPO).as_posix() for p in prompt_surface.SNAPSHOT.rglob("*") if p.is_file())
|
||||
attrs = subprocess.run(["git", "check-attr", "--stdin", "eol"], cwd=REPO, input=files,
|
||||
capture_output=True, text=True, check=True).stdout.splitlines()
|
||||
assert attrs and [line for line in attrs if not line.endswith(": eol: lf")] == []
|
||||
|
||||
|
||||
def test_summary_names_the_surface_and_tool_that_changed(tmp_path):
|
||||
base = prompt_surface.SNAPSHOT
|
||||
head = tmp_path / "head"
|
||||
|
||||
Reference in New Issue
Block a user