-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·39 lines (33 loc) · 1.81 KB
/
pre-commit
File metadata and controls
executable file
·39 lines (33 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
allowbubble=$(git config --bool hooks.allowbubble)
if [ "$allowbubble" != "true" ]
then
bold="`tput bold`"
normal="`tput sgr0`"
ERR_PRE="\n${bold}ERROR:${normal}\n\n COMMIT REJECTED Found (${bold}"
ERR_POST="${normal}) references. Please remove them before commiting. Or you can allow the commits with such lines; by setting git with:\n\n > ${bold}git config hooks.allowbubble true${normal}\n\n And check again with:\n\n > ${bold}git config hooks.allowbubble false${normal}\n"
FILES_PATTERN='\.(rb|erb)(\..+)?$'
FORBIDDEN='binding.pry'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo "$ERR_PRE $FORBIDDEN $ERR_POST" && exit 1
FILES_PATTERN='\.(js|coffee)(\..+)?$'
FORBIDDEN='console.log'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo "$ERR_PRE $FORBIDDEN $ERR_POST" && exit 1
FILES_PATTERN='\.py(\..+)?$'
FORBIDDEN='import pdb'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n "$FORBIDDEN" && echo "$ERR_PRE $FORBIDDEN $ERR_POST" && exit 1
FILES_PATTERN='\.py(\..+)?$'
FORBIDDEN='pdb.set_trace()'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n "$FORBIDDEN" && echo "$ERR_PRE $FORBIDDEN $ERR_POST" && exit 1
FILES_PATTERN='\.py(\..+)?$'
FORBIDDEN='import ipdb'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n "$FORBIDDEN" && echo "$ERR_PRE $FORBIDDEN $ERR_POST" && exit 1
fi