Pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. In short it allows for a self-maintained list of checks to be performed before any commit.
How do I install pre-commit?¶
Pre-commit can be installed in two ways, using Python pip or Homebrew.
- Verify that pip is installed with
- If it isn't installed download and install a newer version of Python, it should include pip as well.
- Verify that brew is installed with
- If it isn't installed, install using
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"(As usual, verify all install scripts before executing)
- Remember to perform the next steps that are shown after install.
pip install pre-commit
brew install pre-commit
Once pre-commit is installed you need to set up the git hook scripts by running
pre-commit install. Now pre-commit wil automatically run on git commit!
How do I add pre-commit to my repository?¶
- Once pre-commit is installed you can add plugins to the
- The config file should be added to the root of your project.
- More guides can be found on the pre-commit website
- You can also generate a basic configuration using
Do I need to setup pre-commit for each repository?¶
Each repository that uses pre-commit needs to have the