Merge "add pre-commit"

This commit is contained in:
Zuul 2023-06-02 10:08:04 +00:00 committed by Gerrit Code Review
commit c6afc1bc8f
2 changed files with 42 additions and 0 deletions

27
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,27 @@
---
default_language_version:
# force all unspecified python hooks to run python3
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: '.*\.(svg)$'
- id: check-byte-order-marker
- id: check-merge-conflict
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: local
hooks:
- id: flake8
name: flake8
additional_dependencies:
- hacking>=3.0.1,<3.1.0
language: python
entry: flake8
files: '^.*\.py$'
exclude: '^(doc|releasenotes|tools)/.*$'

View File

@ -45,3 +45,18 @@ Masakari Specific Commandments
- [M332] Yield must always be followed by a space when yielding a value.
- [M333] Policy registration should be in the central location ``masakari/policies/``
- [M334] Do not use the oslo_policy.policy.Enforcer.enforce() method.
Use of pre-commit checks
------------------------
`pre-commit`_ is a software tool that allows us to manage pre-commit checks as
part of the Git repository's configuration
and to run checks as Git pre-commit hooks (or other types of Git hooks)
automatically on developer machines.
It helps to catch and fix common issues before they get pushed to the server.
After the installation of the tool (e.g. on Fedora via
`sudo dnf install pre-commit`) simply `cd` to the Git repository and run
`pre-commit install` to let the tool install its Git pre-commit hook.
From now on these predefined checks will run on files that you change in new
Git commits.
.. _pre-commit: https://pre-commit.com/