Skip to content

Instantly share code, notes, and snippets.

@graphicagenda
Forked from mythmon/post-receive
Last active November 29, 2019 22:38
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 graphicagenda/2390707 to your computer and use it in GitHub Desktop.
Save graphicagenda/2390707 to your computer and use it in GitHub Desktop.
[The post-receive hook that allows to selectively run git hooks.] #LegacyGISTS
#!/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