aboutsummaryrefslogtreecommitdiff
path: root/.githooks/generic
blob: 6f903dc05edb7a91ef9b56810836c540f4a9a94a (plain)
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
30
31
32
33
#!/bin/sh
#
# A generic git hook proxy.
# https://git-scm.com/docs/githooks

run() {
  hook=$1
  file=$2

  n=$(echo "${file}" |sed "s/^.*${hook}\.//")
  echo "running ${n} ${hook}"
  ${file}
}

die() {
  hook=$1
  echo "${hook} hook did not succeed" >&2
  exit 1
}

# Redirect output to stderr.
exec 1>&2

githooks='.githooks'
basename=$(basename "$0")

for f in $(cd ${githooks} && echo *); do
  case "${f}" in
    ${basename}.*)
      run ${basename} "${githooks}/${f}" || die "${f}"
      ;;
  esac
done