summaryrefslogtreecommitdiff
path: root/.githooks/pre-commit
blob: df918d85fc3842e517d9b93a0d083e149c275f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
set -eu

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 ':(glob)site/*/Caddyfile'; then
    echo "Caddyfiles were formatted. Review and stage the changes."
    exit 1
fi