summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry J. Webster <hwebs@hwebs.info>2026-11-01 19:08:42 -0600
committerHenry J. Webster <hwebs@hwebs.info>2026-11-01 19:08:42 -0600
commit49c1ed74e091a9f793bd89c28a821f5cad5668aa (patch)
tree62bab50b902812d661c6c80ca8715492450e6bf5
parent7445e66158de7b2df43f9f07cc586d01c4c1fccb (diff)
Improve pre-commit hook
The pre-commit hook now - Looks for all Caddyfiles under `site/*/Caddyfile` - Doesn't run if no Caddyfiles have changed
-rwxr-xr-x.githooks/pre-commit9
1 files changed, 7 insertions, 2 deletions
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
index 0af6083..df918d8 100755
--- a/.githooks/pre-commit
+++ b/.githooks/pre-commit
@@ -1,11 +1,16 @@
#!/bin/sh
set -eu
-for file in Caddyfile site/cgit/Caddyfile; do
+if git diff --cached --quiet -- Caddyfile ':(glob)site/*/Caddyfile'; then
+ exit 0
+fi
+
+for file in Caddyfile site/*/Caddyfile; do
+ [ -f "$file" ] || continue
caddy fmt --overwrite "$file"
done
-if ! git diff --quiet -- Caddyfile site/cgit/Caddyfile; then
+if ! git diff --quiet -- Caddyfile ':(glob)site/*/Caddyfile'; then
echo "Caddyfiles were formatted. Review and stage the changes."
exit 1
fi \ No newline at end of file