Skip to content

Instantly share code, notes, and snippets.

@kvendrik
Last active November 25, 2015 16:47
Show Gist options
  • Select an option

  • Save kvendrik/3365296574fe7ecb47a6 to your computer and use it in GitHub Desktop.

Select an option

Save kvendrik/3365296574fe7ecb47a6 to your computer and use it in GitHub Desktop.
pre-push hook example for running tests before pushing to master
# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty
printf "About to push to remote...\n"
# read user input with <message>, continue when input length is <n>
read -p "Run some checks first? [Y/n] " -n 1 cont
printf "\n"
if [ "$cont" == "n" ] || [ "$cont" == "N" ]; then
exit 0
else
grunt jshint
fi
exit 0
# creates symlinks for all git hooks in ./hooks
# from .git/hooks/<HOOK_NAME> to ./hooks/<HOOK_NAME>
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
GIT_HOOK_DIR="$(git rev-parse --show-toplevel)/.git/hooks"
HOOK_DIR="$SCRIPT_DIR/hooks"
cd $HOOK_DIR
for hook in *
do
SYMLINK_PATH="$GIT_HOOK_DIR/$hook"
echo "Symlinking $SYMLINK_PATH to $HOOK_DIR/$hook..."
ln -s -f $HOOK_DIR/$hook $SYMLINK_PATH
chmod 755 $SYMLINK_PATH
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment