#!/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 '\.(py)$')
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. Fix before commit."
  exit 1
fi
echo "Check doc styles for $files"
pydocstyle pymatgen/dao.py $files
if [ $? -ne 0 ]; then
  echo "Bad doc style detected. Fix before commit."
  exit 1
fi