On the git side : you can add a pre-push hook in your local repo to scan for a forbidden word in your code, and cancel the push if word is found.
Here is for example some code that looks for dontpush
(it uses git grep -i
, any casing of "DoNtPuSh"
will work) and will not push if it is found in your local commit :
# file '.git/hooks/pre-push' :
#!/bin/bash
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Delete: nothing to do on deleted branches
else
# Check if "dontpush" appears in the local commit :
dontpush=`git grep -n -i dontpush $local_sha -- $files`
if [ -n "$dontpush" ]
then
# print 'git grep' output on STDERR,
# remove the leading "sha:" on each line
(echo $dontpush | sed -e 's/^[^:]*://') | cat >&2
echo >&2 "*** Found 'dontpush' tag in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0