| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# A generic git hook proxy. |
| 4 |
# https://git-scm.com/docs/githooks |
| 5 |
|
| 6 |
run() { |
| 7 |
hook=$1 |
| 8 |
file=$2 |
| 9 |
|
| 10 |
n=$(echo "${file}" |sed "s/^.*${hook}\.//") |
| 11 |
echo "running ${n} ${hook}" |
| 12 |
${file} |
| 13 |
} |
| 14 |
|
| 15 |
die() { |
| 16 |
hook=$1 |
| 17 |
echo "${hook} hook did not succeed" >&2 |
| 18 |
exit 1 |
| 19 |
} |
| 20 |
|
| 21 |
# Redirect output to stderr. |
| 22 |
exec 1>&2 |
| 23 |
|
| 24 |
githooks='.githooks' |
| 25 |
basename=$(basename "$0") |
| 26 |
|
| 27 |
for f in $(cd ${githooks} && echo *); do |
| 28 |
case "${f}" in |
| 29 |
${basename}.*) |
| 30 |
run ${basename} "${githooks}/${f}" || die "${f}" |
| 31 |
;; |
| 32 |
esac |
| 33 |
done |