-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
executable file
·38 lines (31 loc) · 1.16 KB
/
pre-commit
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
#!/bin/sh
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty
count=$(fgrep -rl ':focus => true' spec/* | grep -v spec_helper.rb | wc -l)
if [[ $count -ne '0' ]] ; then
echo "############## NO COMMIT ####################"
echo "Remove focus tag before commiting in files:"
fgrep -rl ':focus => true' spec/* | grep -v spec_helper.rb
echo "###################################################"
exit 1
fi
prevented_terms=( "binding.pry" "debugger" "Date.tomorrow" "Date.today" )
for i in "${prevented_terms[@]}"
do
count=$(fgrep -rl "$i" {app,config,db,lib,script,spec} | wc -l)
if [[ $count -ne '0' ]] ; then
while true; do
read -p "Some of your code using $i. Do you wanna commit it? (y/n/l) " yn
case $yn in
l | L ) fgrep -rl "$i" {app,config,db,lib,script,spec};;
[Yy]* ) exit;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
done