You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
1.3 KiB

name: Check Git attributes
on:
pull_request:
jobs:
check-gitattributes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for line ending violations
run: |
# Re-normalize all files according to .gitattributes
git add --renormalize .
# Check if renormalization changed anything
if git diff --cached --name-only | grep -q .; then
echo "::error::The following files have line endings that don't match .gitattributes settings:"
git diff --cached --name-only
echo ""
echo "To fix, run:"
echo " git add --renormalize ."
echo " git commit -m 'Normalize line endings'"
exit 1
fi
echo "All files have correct line endings."
- name: Check for trailing whitespace
run: |
if ! git diff --check \
"${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" \
-- ':(attr:text)' ':(attr:text=auto)'; then
echo "::error::Trailing whitespace found in the pull request."
echo "Remove trailing spaces and tabs from added lines."
exit 1
fi
echo "No trailing whitespace found in the pull request."