forked from angrygeese/HW4_Functions2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
36 lines (27 loc) · 939 Bytes
/
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
#!/bin/bash
echo "Hi! I'm your pre-commit code checker."
FILE="dna_rna_tools.py"
TESTS="${FILE%.py}_test.py"
if [ -f $FILE ]; then
if [ ! -f hooks_env/bin/activate ]; then
echo "For the first time I need to prepare an environment, give me a minute..."
python3 -m venv hooks_env
source hooks_env/bin/activate
python3 -m pip install --upgrade pip --quiet
pip install pytest flake8 flake8-bugbear pep8-naming flake8-builtins flake8-functions-names flake8-variables-names pep8-naming pylint mypy --quiet
echo "hooks_env" >> .gitignore
echo ".gitignore" >> .gitignore
else
source hooks_env/bin/activate
fi
echo "$(tput setab 7 setaf 1)>>>> Code quality checks <<<<$(tput sgr 0)"
echo ">>>> flake8 check"
flake8 $FILE
echo ">>>> pylint check"
pylint $FILE
echo ">>>> mypy check"
mypy $FILE
deactivate
else
echo "Seems no python code to be checked. You can configure me in .git/hook/pre-commit"
fi