Skip to content

Instantly share code, notes, and snippets.

@jeremysears jeremysears/pre-push
Last active Feb 26, 2020

Embed
What would you like to do?
An interactive Git pre-push hook to prevent submission of FIXME tags, unless acknowledged.
#!/usr/bin/env bash
matches=$(git diff HEAD~1 HEAD | grep -E '\+.*?FIXME')
if [ "$matches" != "" ]; then
echo >&2 "A 'FIXME' tag has been detected. Please fix all 'FIXME' tags before committing."
echo >&2 ""
echo >&2 "Matching FIXME:"
echo >&2 "${matches}"
echo >&2 ""
echo >&2 "Type 'FIXME' if you would like to commit anyway, otherwise press any key:"
exec < /dev/tty
read -p "(FIXME|any key)>: " ack
if [ "${ack}" != "FIXME" ]; then
echo >&2 "Exiting... Please fix any 'FIXME' tags and resubmit." && exit 1
fi
echo "Ignoring 'FIXME' and pushing anyway"
exec <&-
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.