diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..887afc6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Hash and immutable-file checks compare raw bytes, so text files must have the same line +# endings on every machine. Git's binary detection leaves images and archives alone. +* text=auto eol=lf diff --git a/tests/unit/test_line_endings.py b/tests/unit/test_line_endings.py new file mode 100644 index 0000000..ed6e964 --- /dev/null +++ b/tests/unit/test_line_endings.py @@ -0,0 +1,31 @@ +"""Hash and immutable-file checks read raw bytes, so a checkout must not convert line endings.""" + +from __future__ import annotations + +import subprocess +from pathlib import Path + +import pytest + +pytestmark = pytest.mark.no_seeded_repo + +REPO = Path(__file__).resolve().parents[2] + + +@pytest.mark.parametrize( + "path", + [ + "content/mt/source_snapshots/mt.f352dcdea73daa036a807af6/source_tokens.json", + "content/audit/packages/source_policy.ab4537d9ff4ed35bb62e4059.json", + "app/services/greek_lexical_forms.py", + ], +) +def test_byte_checked_files_check_out_with_lf(path: str) -> None: + result = subprocess.run( + ["git", "check-attr", "eol", "--", path], + cwd=REPO, + capture_output=True, + text=True, + check=True, + ) + assert result.stdout.strip() == f"{path}: eol: lf"