forked from materialsproject/pymatgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
executable file
·30 lines (29 loc) · 951 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
#!/bin/bash
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
status=0
files=$(git diff --diff-filter=d --cached --name-only | grep -E 'pymatgen.*\.(py)$' | sed '/test_/d')
files=`echo $files | tr '\n' ' '`
echo "Check code styles for $files"
pycodestyle pymatgen/dao.py $files
if [ $? -ne 0 ]; then
echo "Bad code style detected by pycodestyle. Fix before commit."
exit 1
fi
echo "Flake8 for $files"
flake8 pymatgen/dao.py $files
if [ $? -ne 0 ]; then
echo "Bad code style detected by flake8. Fix before commit."
exit 1
fi
echo "Check doc styles for $files"
pydocstyle --match='(?!test_).*\.py' pymatgen/dao.py $files
if [ $? -ne 0 ]; then
echo "Bad doc style detected. Fix before commit."
exit 1
fi