Skip to content

Instantly share code, notes, and snippets.

@paunin
Created August 11, 2014 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paunin/afa6b7cca31e9fbfdf02 to your computer and use it in GitHub Desktop.
Save paunin/afa6b7cca31e9fbfdf02 to your computer and use it in GitHub Desktop.
Gitolite update.secondary
#!/bin/sh
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment