all repos — shwarp.ca @ ad1f955a35fb03a2245602918bc39f430052698d

Homepage repo

config/git/hooks/pre-commit (view raw, download)

 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
#!/bin/bash

# Redirect output to stderr.
exec 1>&2

# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty

function prompt {
    while true; do
        read -p "$1 [y]es or [n]o " yn
        case $yn in
            [Yy]* ) return 0;;
            [Nn]* ) return 1;;
            * ) echo "Please answer yes or no.";;
        esac
    done
}

./scripts/gen-nginx-rewrites > ./config/pages.redirects

git diff --exit-code ./config/pages.redirects
if [[ $? -ne 0 ]]
then
    echo "You forgot to generate page redirects..."
    prompt "Commit anyway?" || exit 1
fi

exit 0