mirror of
https://github.com/itflow-org/itflow
synced 2026-08-17 04:55:13 +00:00
Normalize line endings to LF; add .gitattributes and .editorconfig
This commit is contained in:
20
.editorconfig
Normal file
20
.editorconfig
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Editor defaults for ITFlow - see CONTRIBUTING.md ("Style")
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
# Vendored - do not reformat
|
||||||
|
[libs/**]
|
||||||
|
indent_style = unset
|
||||||
|
indent_size = unset
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
insert_final_newline = false
|
||||||
44
.gitattributes
vendored
Normal file
44
.gitattributes
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# ITFlow line-ending policy
|
||||||
|
#
|
||||||
|
# Everything ITFlow ships is LF in the repository and LF in the working tree.
|
||||||
|
# Contributors on Windows get LF too - this is deliberate. ITFlow is deployed
|
||||||
|
# to Linux/Apache and edited over sftp/ssh as often as it is cloned, so a
|
||||||
|
# checkout must be byte-identical everywhere.
|
||||||
|
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
# Explicit for the file types we author, so nothing depends on git's guess.
|
||||||
|
*.php text eol=lf
|
||||||
|
*.js text eol=lf
|
||||||
|
*.css text eol=lf
|
||||||
|
*.html text eol=lf
|
||||||
|
*.sql text eol=lf
|
||||||
|
*.md text eol=lf
|
||||||
|
*.json text eol=lf
|
||||||
|
*.yml text eol=lf
|
||||||
|
*.xsd text eol=lf
|
||||||
|
*.svg text eol=lf
|
||||||
|
*.txt text eol=lf
|
||||||
|
*.ini text eol=lf
|
||||||
|
.htaccess text eol=lf
|
||||||
|
|
||||||
|
# Binary assets: never touched, never diffed as text.
|
||||||
|
*.png binary
|
||||||
|
*.gif binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.webp binary
|
||||||
|
*.ico binary
|
||||||
|
*.icc binary
|
||||||
|
*.woff binary
|
||||||
|
*.woff2 binary
|
||||||
|
*.ttf binary
|
||||||
|
*.eot binary
|
||||||
|
*.crt binary
|
||||||
|
*.ser binary
|
||||||
|
*.z binary
|
||||||
|
|
||||||
|
# Vendored third-party code is preserved byte-for-byte as shipped upstream.
|
||||||
|
# Per CONTRIBUTING.md libs/ is never edited in place - it is replaced wholesale -
|
||||||
|
# so normalizing it here would create spurious diffs on the next library update.
|
||||||
|
libs/** -text
|
||||||
30
normalize_eol.sh
Normal file
30
normalize_eol.sh
Normal 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)"
|
||||||
30
scripts/normalize_eol.sh
Executable file
30
scripts/normalize_eol.sh
Executable 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)"
|
||||||
Reference in New Issue
Block a user