forked from materialsproject/pymatgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·21 lines (20 loc) · 746 Bytes
/
pre-commit
File metadata and controls
executable file
·21 lines (20 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
#
# To use this pre-commit hook, copy this file to your .git/hooks directory.
# It is always better to run the linters BEFORE you push to Github rather
# than wait for Github to run the linters slowly.
# You will need to install all the linters, which can be done using:
# pip install -r requirements-dev.txt
files=$(git diff --diff-filter=d --cached --name-only | grep -E 'pymatgen.*\.(py)$' | sed '/test_/d' | sed '/tests/d')
files=$(echo "$files" | tr '\n' ' ')
if [ "$files" != " " ]; then
for cmd in mypy pydocstyle pylint black flake8
do
echo "Running $cmd $files..."
$cmd $files
if [ $? -ne 0 ]; then
echo "$cmd failed. Fix before commit."
exit 1
fi
done
fi