diff options
| author | Henry J. Webster <hwebs@hwebs.info> | 2026-11-01 19:08:42 -0600 |
|---|---|---|
| committer | Henry J. Webster <hwebs@hwebs.info> | 2026-11-01 19:08:42 -0600 |
| commit | 49c1ed74e091a9f793bd89c28a821f5cad5668aa (patch) | |
| tree | 62bab50b902812d661c6c80ca8715492450e6bf5 /.githooks/pre-commit | |
| parent | 7445e66158de7b2df43f9f07cc586d01c4c1fccb (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
Diffstat (limited to '.githooks/pre-commit')
| -rwxr-xr-x | .githooks/pre-commit | 9 |
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 |
