Upload .github/workflows/check-line-endings.yml with huggingface_hub
Browse files
.github/workflows/check-line-endings.yml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Check for Windows Line Endings
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
branches: ['*'] # Trigger on all pull requests to any branch
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
check-line-endings:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout code
|
| 13 |
+
uses: actions/checkout@v4
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0 # Fetch all history to compare changes
|
| 16 |
+
|
| 17 |
+
- name: Check for Windows line endings (CRLF)
|
| 18 |
+
run: |
|
| 19 |
+
# Get the list of changed files in the PR
|
| 20 |
+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- ':!.ci')
|
| 21 |
+
|
| 22 |
+
# Flag to track if CRLF is found
|
| 23 |
+
CRLF_FOUND=false
|
| 24 |
+
|
| 25 |
+
# Loop through each changed file
|
| 26 |
+
for FILE in $CHANGED_FILES; do
|
| 27 |
+
# Check if the file exists and is a text file
|
| 28 |
+
if [ -f "$FILE" ] && file "$FILE" | grep -q "text"; then
|
| 29 |
+
# Check for CRLF line endings
|
| 30 |
+
if grep -UP '\r$' "$FILE"; then
|
| 31 |
+
echo "Error: Windows line endings (CRLF) detected in $FILE"
|
| 32 |
+
CRLF_FOUND=true
|
| 33 |
+
fi
|
| 34 |
+
fi
|
| 35 |
+
done
|
| 36 |
+
|
| 37 |
+
# Exit with error if CRLF was found
|
| 38 |
+
if [ "$CRLF_FOUND" = true ]; then
|
| 39 |
+
exit 1
|
| 40 |
+
fi
|