Revisions
-
pmoranga revised this gist
May 24, 2022 . 3 changed files with 61 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ ## Example using https://pre-commit.com/ repos: - repo: local hooks: - id: dontship name: DONTSHIP check - Block words entry: '\bdie\b' language: pygrep # https://pre-commit.com/#pygrep types: [php] - id: check-swear name: Check Swear Words entry: ./scripts/check_swear_words.sh language: script This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ #!/bin/bash ## This script should run under pre-commit control and return error in case of any bad word is present in the files staged # If you want to commit something with swearing use FUCK_IT=1 git commit ... if [ -n "$FUCK_IT" ]; then exit 0 fi ROOT_DIR=$(git rev-parse --show-toplevel) EXIT=0 # Definitely NSFW WORD_FILE_URL_BASE="https://raw.githubusercontent.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words/master/" WORD_FILE_PATH_BASE=~/.swearwords TMPFILE=$(mktemp) check_for_words(){ LANG=$1 if [ ! -f "${WORD_FILE_PATH_BASE}-${LANG}" ]; then wget -q -O - "${WORD_FILE_URL_BASE}/${LANG}" | tr '\n' '|' | sed 's/\|$//g' > "${WORD_FILE_PATH_BASE}-${LANG}" fi PATTERN="$(cat ${WORD_FILE_PATH_BASE}-${LANG} )" if [[ -n "$PATTERN" ]]; then for file in $(git diff --cached --name-only --diff-filter=ACM); do if egrep -Hinw "$PATTERN" "$file" > $TMPFILE ; then echo "Swear word with language: ${LANG} found in file: $(cat $TMPFILE)" rm $TMPFILE return 1 fi done fi return 0 } for i in en fr pt ru it es; do check_for_words $i || exit 1 done rm $TMPFILE exit 0 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,33 +0,0 @@ -
skwashd revised this gist
Jan 31, 2014 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,11 @@ # Please don't use this fucking script, it is shit! # # If you want to commit something with swearing use FUCK_IT=1 git commit ... if [ ! -z "$FUCK_IT" ]; then exit 0 fi ROOT_DIR=$(git rev-parse --show-toplevel) EXIT=0 -
skwashd revised this gist
Jan 31, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ fi PATTERN="$(cat $WORD_FILE_PATH)" for file in $(git diff --cached --name-only --diff-filter=ACM); do if egrep -Hin "$PATTERN" $file; then EXIT=1 fi done -
skwashd created this gist
Jan 31, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash -e # # Git pre-commit hook that blocks commits for files that contain swear words. # # Created by Dave Hall - http://davehall.com.au # Distributed under the terms of the WTFPL - http://www.wtfpl.net/ # # Please don't use this fucking script, it is shit! # ROOT_DIR=$(git rev-parse --show-toplevel) EXIT=0 # Definitely NSFW WORD_FILE_URL="http://www.bannedwordlist.com/lists/swearWords.csv" WORD_FILE_PATH=~/.swearwords.csv if [ ! -f $WORD_FILE_PATH ]; then wget -q --header="User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11" --header="Referer: https://google/" -O - "$WORD_FILE_URL" | tr , '|' > $WORD_FILE_PATH fi PATTERN="$(cat $WORD_FILE_PATH)" for file in $(git diff --cached --name-only --diff-filter=ACM); do if egrep -Hinw "$PATTERN" $file; then EXIT=1 fi done exit $EXIT