generated from will-ks/next-hasura-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-commits.sh
52 lines (44 loc) · 1.08 KB
/
check-commits.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='^\+.*console\.log\('
fooregexp='^\+.*foo'
testonlyregexp='^\+.*\.only(\(|\.)'
if test `git diff --cached | egrep $consoleregexp | wc -l` != 0
then
exec git diff --cached | egrep "($consoleregexp|\+{3})"
read -p "There are some 'console.log' calls in the diff. Do you want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
continue;
else
exit 1;
fi
fi
if test `git diff --cached | egrep $fooregexp | wc -l` != 0
then
exec git diff --cached | egrep "($fooregexp|\+{3})"
read -p "There are some 'foo's in the diff. Do you want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
continue;
else
exit 1;
fi
fi
if test `git diff --cached | egrep $testonlyregexp | wc -l` != 0
then
exec git diff --cached | egrep "($testonlyregexp|\+{3})"
read -p "There might be some '.only' Testcafe calls in the diff. Do you want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
exit 0;
else
exit 1;
fi
fi