Skip to content

Instantly share code, notes, and snippets.

@AlexChittock
Created April 12, 2012 14:00
Show Gist options
  • Save AlexChittock/2367494 to your computer and use it in GitHub Desktop.
Save AlexChittock/2367494 to your computer and use it in GitHub Desktop.
Expands a git hook event to execute multiple scripts
#!/bin/sh
#
# Executes multiple scripts on a git event
#
# Expects scripts to be arranged like:
# some/directory/for/hooks/
# pre-commit/
# safe-debug.sh
# validate.sh
# update/
# email.sh
#
# So for the update hook, we'd set HOOK_DIR as
#
# HOOK_DIR="some/directory/for/hooks/"
#
# and save the file as ".git/hooks/update"
#
# Edit this line
HOOK_DIR="tools/hooks/"
# Don't edit these
hook=`basename $0`
dir=$HOOK_DIR$hook
if [ -d $dir ]; then
echo "Executing "$hook" hooks";
find $dir -name '*.sh' -exec {} \;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment