git-hooks/pre-commit-todos/pre-commit

23 lines
685 B
Bash
Executable File

#!/bin/bash
#
# Pre commit hook that Warns about code being commited.
# Add unwanted code to the WARNING array as necessary
WARNING=( "TODO-WARN:" )
for i in "${WARNING[@]}"
do
git diff --cached --name-only | \
GREP_COLOR='7;4;37;41' xargs grep --color --with-filename -n $i
done
# Pre commit hook that prevents FORBIDDEN code from being commited.
# Add unwanted code to the FORBIDDEN array as necessary
FORBIDDEN=( "TODO:" )
for i in "${FORBIDDEN[@]}"
do
git diff --cached --name-only | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $i && \
echo 'COMMIT REJECTED Found' $i 'references. Please remove them before commiting' && exit 1
done
exit $ERR