nova/tools/flake8wrap.sh
Stephen Finucane 5f8dd65f6c Integrate 'pre-commit'
This nifty tool provides a extensible way to configure pre-commit hooks
to do everything from running linters to spellchecking [1] and has
already been adopted by a few OpenStack projects [2]. Let's start using
it as a faster, more automatic alternative to the 'fast8' tox target and
iterate on it as we find more things to use it for. The 'fast8' target
is not deprecated though a note is included for end-users to alert them
to this great new tool.

Note that the 'check-executables-have-shebangs' actually failed and
highlighted that the 'contributor/development-environment.rst' document
was marked as executable when it shouldn't have been. This is corrected.

[1] https://pre-commit.com/
[2] https://review.opendev.org/#/q/file:.pre-commit-config.yaml

Change-Id: I256e75eceeb3495dce04885ca42d16adb4160cf3
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-11-28 12:46:55 +00:00

28 lines
682 B
Bash
Executable File

#!/bin/sh
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
echo ""
echo "Consider using the 'pre-commit' tool instead."
echo ""
echo " pip install --user pre-commit"
echo " pre-commit install --allow-missing-config"
echo ""
diff -u --from-file /dev/null ${files} | flake8 --diff "$@"
else
echo "Running flake8 on all files"
echo ""
exec flake8 "$@"
fi