Skip to content

Instantly share code, notes, and snippets.

@gsomoza
Created July 23, 2015 09:36
Show Gist options
  • Save gsomoza/5f05296b55b86828a1d2 to your computer and use it in GitHub Desktop.
Save gsomoza/5f05296b55b86828a1d2 to your computer and use it in GitHub Desktop.
Git pre-push hook for Ant
#!/bin/bash
# FILE: .git/hooks/pre-push
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
read -p "You're about to push $current_branch. Did you already build with Ant? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
then
exit 0 # push will execute
fi
echo "Building, please wait..."
ANT_RESULT=`ant`
ANT_EXIT=$?
echo "$ANT_RESULT"
exit $ANT_EXIT # push will execute if Ant succeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment