-
-
Notifications
You must be signed in to change notification settings - Fork 137
35 lines (31 loc) · 996 Bytes
/
Copy pathlint-line-endings.yml
File metadata and controls
35 lines (31 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Line Ending Linter
on:
push:
branches: ["**"] # Runs on every push to every branch
pull_request:
branches: ["**"]
permissions:
contents: read
jobs:
check-crlf:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Scan for CRLF (\r)
run: |
# List files with \r, excluding the .git directory
BAD_FILES=$(grep -rIl $'\r' --exclude-dir=.git --exclude-dir=windows . || true)
if [ -n "$BAD_FILES" ]; then
echo "ERROR: CRLF (Windows) line endings detected!"
echo "The following files must be LF:"
echo "$BAD_FILES"
echo ""
echo "FIX: Run these commands on your machine:"
echo " git add --renormalize ."
echo " git commit -m 'fix: normalize line endings'"
echo " git push"
exit 1
else
echo "OK: All files are clean (LF)."
fi