aboutsummaryrefslogtreecommitdiff
blob: e02147229c69f3c3349f7f2ca3060331307adb51 (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
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# gentoo-infra: infra/githooks.git:local/update.secondary

# driver script to run multiple update "hooklets".  Each "hooklet" performs a
# specific (possibly site-local) check, and they *all* have to succeed for the
# push to succeed.

# HOW TO USE:

# (1) rename this file to remove the .sample extension
# (2) make the renamed file executable (chmod +x)
# (3) put it in ~/.gitolite/hooks/common on the server
# (4) create a directory called update.secondary.d in the same place
# (5) copy all the update "hooklets" you want (like update.detect-dup-pubkeys)
#     from contrib or wherever, to that directory
# (6) make them also executable (chmod +x)
# (7) run gl-setup

# rules for writing a hooklet are in the sample hooklet called
# "update.detect-dup-pubkeys" in contrib

# ----

# NOTE: a hooklet runs under the same assumptions as the 'update' hook, so the
# starting directory must be maintained and arguments must be passed on.

[ -d hooks/update.secondary.d ] || exit 0

# all output from these "hooklets" must go to STDERR to avoid confusing the client
exec >&2

for i in hooks/update.secondary.d/*
do
    [ -x "$i" ] || continue
    # call the hooklet with the same arguments we got
    "$i" "$@"   || {
        # hooklet failed; we need to log it...
        echo hooklet "$i" failed
        perl -I"$GL_BINDIR" -Mgitolite -e "log_it('hooklet $i failed')"
        # ...and send back some non-zero exit code ;-)
        exit 1
    }
done

exit 0