forked from bugsink/bugsink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·32 lines (26 loc) · 1.08 KB
/
pre-commit
File metadata and controls
executable file
·32 lines (26 loc) · 1.08 KB
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
#!/bin/sh
# this script must be placed in .git/hooks/pre-commit for it to run automatically
# it is put here in the repo so that it can be used by anyone who clones the repo
# it assumes the environment to run `python manage.py tailwind build` is already set up
# and activated
should_run=$(git diff --cached --name-only -z | python tools/is_tracked_by_tailwind.py)
if [ "$should_run" = "yes" ]; then
echo "Building Tailwind CSS..."
python manage.py tailwind build
git add theme/static/css/dist/styles.css
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