Git pre commits are quite useful to analyze the code before you make a commit and pre-commit makes it quite easy to mange these hooks and rules to run via these hooks.
- Install pre-commit, pip install pre-commit ## detailed instruction on it's website pre-commit
- Run
pre-commit install
## Usage instruction on it's website pre-commit - Create .pre-commit-config.yaml file in your project root
- I have added it to behave-selenium, check it out
pre-commit install will install pre-commit into your git hooks, now on words it will be run on every commit.
Every time you clone a project running
pre-commit install
should always be the first thing you do.
The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.
- To Run all pre-commit manually on all file type
pre-commit run --all-files
- To run specific hook (via the id in .pre-commit-config.yaml) on specific file(s)
pre-commit run autopep8-wrapper --files features/steps/google_steps.py
We can also run all the pre commit hook as a CI step e.g. pre-commit run --all-files
Individual tools can configure in accordance to according to there configuration. For example flake8 can be configured by adding a setup.cfg file
Individual tools can configure in accordance to according to there configuration. For example flake8 can be configured by adding a setup.cfg file
No comments:
Post a Comment