E.g pycharm has nice feature of warning user before commiting code containing 'TODO'... I would like to have something like that in my standard command line used git. I heard it will be possible using git pre-hook. I will appreciate some hint how to accomplish that nice.
As a simple solution, you could save the following shell script as .git/hooks/pre-commit:
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=AM)
if [ -n "$files" ]; then
if grep -H TODO $files; then
echo "Blocking commit as TODO was found."
exit 1
fi
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With