graphicagenda
4/15/2012 - 7:20 AM

The post-receive hook that allows to selectively run git hooks.

[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