mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
pre-commit: fail on trailing whitespace
This commit is contained in:
16
pre-commit
16
pre-commit
@@ -14,3 +14,19 @@ if [ "$should_run" = "yes" ]; then
|
||||
else
|
||||
echo "No relevant changes; skipping Tailwind build."
|
||||
fi
|
||||
|
||||
# Check for trailing whitespace in staged files, fail if found
|
||||
|
||||
git diff --cached --name-only --diff-filter=ACM | while IFS= read -r file; do
|
||||
[ -f "$file" ] || continue
|
||||
|
||||
case "$file" in
|
||||
*.py|*.js|*.ts|*.sh|*.md|*.txt|*.html|*.css)
|
||||
if grep -qE '[[:space:]]+$' "$file"; then
|
||||
echo "Commit aborted due to trailing whitespace."
|
||||
echo "Fix it manually or use tools/strip-trailing-whitespace.sh"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user