Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created March 27, 2012 06:07
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 mythmon/2213144 to your computer and use it in GitHub Desktop.
Save mythmon/2213144 to your computer and use it in GitHub Desktop.
The post-receive hook that allows to selectively run git hooks.
#!/bin/bash
# wrapper script for post-recieve
enabled_hooks="$(git config hooks.enabled)"
hooks_path="/usr/local/share/git/hooks/"
if [ -n "${enabled_hooks}" ] ; then
# change separate to comma
OLDIFS="$IFS"
IFS=","
for i in $enabled_hooks ; do
# reset IFS
IFS=$OLDIFS
# remove extra whitespace
hook="${hooks_path}${i//[[:space:]]}"
if [ -f ${hook} ] ; then
echo "executing ${hook}"
. ${hook}
else
echo "warning: ${hook} not found"
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment