Merge "Integrate 'pre-commit'"

This commit is contained in:
Zuul
2019-12-05 12:26:58 +00:00
committed by Gerrit Code Review
3 changed files with 40 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: flake8
additional_dependencies:
- hacking>=1.1.0,<1.2.0
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7
hooks:
- id: remove-tabs
+12
View File
@@ -163,6 +163,18 @@ Note that some unit and functional tests use a database. See the file
``tools/test-setup.sh`` on how the databases are set up in the
OpenStack CI environment and replicate it in your test environment.
Using the pre-commit hook
=========================
Nova makes use of the `pre-commit framework <https://pre-commit.com/>`__ to
allow running of some linters on each commit. This must be enabled locally to
function:
.. code-block:: shell
$ pip install --user pre-commit
$ pre-commit install --allow-missing-config
Using a remote debugger
=======================
+7
View File
@@ -13,8 +13,15 @@ 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