-
-
Save cice/153005554ff5438d0524d6ae428da647 to your computer and use it in GitHub Desktop.
Git Pre Commit Hook for FIXME TODO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# An hook script to verify changes to be committed do not contain | |
# any 'DONTCOMMIT:' comments. Called by "git commit" with no arguments. | |
# | |
# The hook should exit with non-zero status after issuing an appropriate | |
# message if it stops the commit. | |
# | |
# To bypass this hook, use the "--no-verify" parameter when committing. | |
# Redirect output to stderr. | |
exec 1>&2 | |
# Define colors | |
RED='\033[0;31m' | |
NC='\033[0m' | |
# Define what term will be searched for. | |
SEARCH_TERM_DONTCOMMIT="DONTCOMMIT:" | |
# Check for the presence of the SEARCH_TERM in updated files. | |
if [[ $(git diff --cached | grep -E "^\+" | grep -v '+++ b/' | cut -c 2-) == *$SEARCH_TERM_DONTCOMMIT* ]] | |
then | |
printf "${RED}Error:${NC} Found ${SEARCH_TERM_DONTCOMMIT} in attempted commit.\n" | |
printf "Please remove all occurances of ${SEARCH_TERM_DONTCOMMIT} before committing.\n" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment