chore: every text file LF by default, and a test that fails on CRLF
5dff54b listed file types; a Dockerfile, .jsonl, .gitignore or any type not
yet invented had no rule. .gitattributes now defaults every file to
`text=auto eol=lf` (Terra-View's rule), marks the binaries, and keeps
tests/fixtures/** -text. Renormalizing under it changes no file.
tests/test_line_endings.py fails if a tracked file outside the fixtures is
stored CRLF, or if the rule stops covering new text types, fixtures or
binaries. Its CRLF detector, pointed at the fixtures, finds all 38.
Suite: 1,711 passed, 0 failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
5dff54b292
commit
77a0296496
2 files changed
+90
-17
No files matched your search
+24
-17
@@ -1,20 +1,27 @@
|
|||||||
# Line endings (2026-11-12): source and docs are stored and checked out with LF,
|
# Line endings (2026-11-12): every text file is stored and checked out with LF,
|
||||||
# whatever tool or OS wrote them. The protocol reference and seismo_lab.py were
|
# whatever tool or OS wrote it -- file types we have not invented yet included.
|
||||||
# CRLF, so any rewrite outside the Edit tool turned them into whole-file diffs.
|
# The protocol reference and seismo_lab.py were CRLF, so any rewrite outside the
|
||||||
*.py text eol=lf
|
# Edit tool turned them into whole-file diffs, and merges into them had to be
|
||||||
*.md text eol=lf
|
# resolved byte by byte. Same rule as Terra-View's. tests/test_line_endings.py
|
||||||
*.js text eol=lf
|
# fails if a CRLF file gets in anyway.
|
||||||
*.html text eol=lf
|
* text=auto eol=lf
|
||||||
*.css text eol=lf
|
|
||||||
*.json text eol=lf
|
# Binary -- never converted.
|
||||||
*.toml text eol=lf
|
*.bin binary
|
||||||
*.yml text eol=lf
|
*.pdf binary
|
||||||
*.yaml text eol=lf
|
*.png binary
|
||||||
*.sh text eol=lf
|
*.jpg binary
|
||||||
*.txt text eol=lf
|
*.jpeg binary
|
||||||
*.csv text eol=lf
|
*.gif binary
|
||||||
*.cfg text eol=lf
|
*.ico binary
|
||||||
*.ini text eol=lf
|
*.h5 binary
|
||||||
|
*.pkl binary
|
||||||
|
*.db binary
|
||||||
|
*.sqlite binary
|
||||||
|
*.zip binary
|
||||||
|
*.gz binary
|
||||||
|
*.xlsx binary
|
||||||
|
*.docx binary
|
||||||
|
|
||||||
# Test fixtures are recorded bytes -- Blastware's own reports and exports, unit
|
# Test fixtures are recorded bytes -- Blastware's own reports and exports, unit
|
||||||
# captures, event files -- kept byte for byte as ground truth: never converted.
|
# captures, event files -- kept byte for byte as ground truth: never converted.
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
"""Line endings (2026-11-12): every tracked text file outside the fixtures is LF.
|
||||||
|
|
||||||
|
.gitattributes defaults every file to `text=auto eol=lf`, so git stores and checks
|
||||||
|
out text as LF whatever wrote it, file types not invented yet included. Binaries
|
||||||
|
are never converted. tests/fixtures/** is -text: recorded bytes (Blastware's own
|
||||||
|
reports and exports, captures, event files) stay exactly as recorded, CRLF and all.
|
||||||
|
|
||||||
|
The protocol reference and seismo_lab.py were CRLF until 5dff54b, so any rewrite
|
||||||
|
outside the Edit tool turned them into whole-file diffs, and merges into them had
|
||||||
|
to be resolved byte by byte.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
|
FIXTURES = "tests/fixtures/"
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.skipif(
|
||||||
|
shutil.which("git") is None or not (ROOT / ".git").exists(), reason="not a git checkout")
|
||||||
|
|
||||||
|
|
||||||
|
def _git(*args: str) -> str:
|
||||||
|
return subprocess.run(["git", "-C", str(ROOT), *args],
|
||||||
|
capture_output=True, text=True, check=True).stdout
|
||||||
|
|
||||||
|
|
||||||
|
def crlf_files(include_fixtures: bool = False) -> list:
|
||||||
|
"""Tracked files stored (in the index) with CRLF or mixed line endings."""
|
||||||
|
out = []
|
||||||
|
for line in _git("ls-files", "--eol").splitlines():
|
||||||
|
meta, path = line.split("\t", 1)
|
||||||
|
if meta.split()[0] in ("i/crlf", "i/mixed") and (include_fixtures or not path.startswith(FIXTURES)):
|
||||||
|
out.append(path)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def attr(name: str, path: str) -> str:
|
||||||
|
return _git("check-attr", name, "--", path).rsplit(": ", 1)[-1].strip()
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_tracked_file_outside_the_fixtures_is_crlf():
|
||||||
|
assert crlf_files() == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", ["sfm/new_module.py", "docs/notes.md", "Dockerfile", "events.jsonl",
|
||||||
|
".gitignore", "deploy/sfm.service", "a.kind-of-file-not-invented-yet"])
|
||||||
|
def test_any_text_file_is_stored_as_lf(path):
|
||||||
|
assert (attr("text", path), attr("eol", path)) == ("auto", "lf")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", ["tests/fixtures/minimate-bench-10-26-26-blastware/blastware/K441LTOG.000",
|
||||||
|
"tests/fixtures/decode-checker-10-29-26/M007HVWF_K30W_XML.XML",
|
||||||
|
"tests/fixtures/new-bench/README.md"])
|
||||||
|
def test_fixtures_are_never_converted(path):
|
||||||
|
assert attr("text", path) == "unset"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("path", ["parsers/raw_bw.bin", "analysis_idf/thor_report.pdf", "docs/photo.png",
|
||||||
|
"docs/photo.jpg", "out/event.h5", "out/event.a5.pkl", "sfm/data/cache.db"])
|
||||||
|
def test_binaries_are_never_converted(path):
|
||||||
|
assert attr("text", path) == "unset"
|
||||||
Reference in new issue
Block a user