Skip to content

Instantly share code, notes, and snippets.

@paunin
Last active April 29, 2016 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paunin/649874a960d4eea1d5d6 to your computer and use it in GitHub Desktop.
Save paunin/649874a960d4eea1d5d6 to your computer and use it in GitHub Desktop.
git hook-chain
#!/bin/bash
# http://stackoverflow.com/questions/8730514/chaining-git-hooks
# author: orefalo
hookname=`basename $0`
FILE=`mktemp`
trap 'rm -f $FILE' EXIT
cat - > $FILE
for hook in $GIT_DIR/hooks/$hookname.*
do
if test -x "$hook"; then
# echo $hook
cat $FILE | $hook "$@"
status=$?
if test $status -ne 0; then
echo Hook $hook failed with error code $status
exit $status
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment