Normalize line endings to LF; add .gitattributes and .editorconfig

This commit is contained in:
johnnyq
2026-07-28 17:45:52 -04:00
parent 7f7880a4a7
commit c5ff3e2a3f
10 changed files with 5156 additions and 5032 deletions

30
scripts/normalize_eol.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# ITFlow - one-shot CRLF -> LF normalization.
#
# Converts every tracked text file outside libs/ to LF. Vendored libraries are
# left byte-for-byte as shipped upstream (CONTRIBUTING.md: libs/ is replaced
# wholesale, never edited), and binary assets are skipped outright.
#
# Run once, from the repo root, alongside adding .gitattributes. After that
# .gitattributes keeps new files in line and this script should be a no-op.
#
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
BINARY_RE='\.(png|gif|jpg|jpeg|webp|ico|icc|woff|woff2|ttf|eot|crt|ser|z)$'
mapfile -t candidates < <(git ls-files | grep -v '^libs/' | grep -viE "$BINARY_RE")
changed=0
for f in "${candidates[@]}"; do
[ -f "$f" ] || continue
# only touch files that actually contain a CR
if LC_ALL=C grep -qU $'\r' "$f" 2>/dev/null; then
LC_ALL=C sed -i 's/\r$//' "$f"
changed=$((changed + 1))
fi
done
echo "normalized $changed file(s)"