Skip to content

Commit

Permalink
Add a git pre-commit hook script
Browse files Browse the repository at this point in the history
The script runs `flake8` and checks consistency of versions set
in `setup.py` and in `docs/conf.py`.
  • Loading branch information
krivenko committed Jan 21, 2024
1 parent 48363ab commit 6c79c66
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/git-pre-commit-check-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env sh

# pre-commit git hook

# Lint the project with flake8
if ! flake8 . ; then
echo "flake8 failed"
exit 1
fi

# Check consistency of versions in setup.py and in docs/conf.py
SETUP_PY_VERSION=$(sed -n "s/^__version__ = \"\([0-9.]*\)\"/\1/p" setup.py)
CONF_PY_VERSION=$(sed -n "s/^version = '\([0-9.]*\)'/\1/p" docs/conf.py)

echo "SETUP_PY_VERSION=${SETUP_PY_VERSION}"
echo "CONF_PY_VERSION=${CONF_PY_VERSION}"

if [ "$SETUP_PY_VERSION" != "$CONF_PY_VERSION" ]; then
echo "Versions don't match"
exit 1
fi

0 comments on commit 6c79c66

Please sign in to comment.