# this is an example how to use git pre-commit hooks on windows to make sure code format is correct.
# Place in .git\hooks and remove the first two lines. (Assuming you have git installed in default path.)
#!C:/Program\ Files/Git/bin/sh.exe
for file in $(git diff --cached --name-only | grep -E '\.(py)$')
  do
	if [ -f "$file" ]; then
		echo "Reformat '$file'"
		black -l 120 "$file"
		isort -l 120 -l 120 --lbt 1 "$file"
		git add "$file"

		flake8 --max-line-length=120 --ignore=F401,W503,E203 "$file"
		if [ $? -ne 0 ]; then
			echo "flake8 failed on staged file '$file'"
			exit 1 # exit with failure status
		fi
	fi
  done
