-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
40 lines (31 loc) · 1.01 KB
/
pre-commit
File metadata and controls
40 lines (31 loc) · 1.01 KB
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
#!/bin/bash
echo "Hi! I'm your pre-commit code checker."
FILE="HW13_OOP.py"
FILE_FASTQ="fastq_filtrator.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
flake8 $FILE_FASTQ
echo ">>>> pylint check"
pylint $FILE
pylint $FILE_FASTQ
echo ">>>> mypy check"
mypy $FILE
mypy $FILE_FASTQ
deactivate
else
echo "Seems no python code to be checked. You can configure me in .git/hook/pre-commit"
fi