forked from TheR1D/shell_gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-push.sh
executable file
·59 lines (50 loc) · 1.21 KB
/
pre-push.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
53
54
55
56
57
58
59
#!/usr/bin/env bash
chmod +x "$PWD/pre-push.sh"
ln -sf "$PWD/pre-push.sh" .git/hooks/pre-push
# Check if pylint is installed
if ! command -v pylint > /dev/null; then
echo "pylint is not installed. Install it with 'pip install pylint'"
exit 1
fi
# Check if black is installed
if ! command -v black > /dev/null; then
echo "black is not installed. Install it with 'pip install black'"
exit 1
fi
echo 'Executing pre-push hook.'
if [ -f "$PWD/venv/bin/activate" ]; then
source $PWD/venv/bin/activate
fi
if black ./sgpt ./tests --check --target-version py310
then
echo 'Black passed ✅'
else
echo 'Black failed ❌'
echo 'RUN: black ./sgpt ./tests --target-version py310'
exit 1
fi
if pylint \
./sgpt \
./tests \
--disable=fixme \
--disable=cyclic-import \
--disable=useless-import-alias \
--disable=missing-function-docstring \
--disable=missing-module-docstring \
--disable=missing-class-docstring \
--disable=too-many-function-args \
--ignore=venv
then
echo 'Pylint passed ✅'
else
echo 'Pylint failed ❌'
exit 1
fi
if python -m unittest tests/unittests.py
then
echo 'Unittests passed ✅'
else
echo 'Unittests failed ❌'
exit 1
fi
echo 'Well done.'