forked from TheR1D/shell_gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-push.sh
executable file
·60 lines (51 loc) · 1.3 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
60
#!/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 --exclude venv --check --target-version py310 -l 120 *.py
then
echo 'Black passed ✅'
else
echo 'Black failed ❌'
echo 'RUN: black --exclude venv --target-version py310 -l 120 *.py'
exit 1
fi
if pylint \
*.py \
--disable=missing-function-docstring \
--disable=too-many-arguments \
--disable=missing-module-docstring \
--disable=import-error \
--disable=missing-class-docstring \
--disable=too-many-instance-attributes \
--disable=too-many-function-args \
--disable=unspecified-encoding \
--max-line-length=120 \
--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.'