Evan Harmon - Memex

Pre-commit

Add pre-commit to project

  • create a file named .pre-commit-config.yaml to the root of your project
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
    -   id: check-yaml
    -   id: end-of-file-fixer
    -   id: trailing-whitespace
-   repo: https://github.com/psf/black
    rev: 22.10.0
    hooks:
    -   id: black
  • pre-commit install
  • git add .pre-commit-config.yaml and commit to your repo and it should work.
    it's usually a good idea to run the hooks against all of the files when adding new hooks (usually pre-commit will only run on the changed files during git hooks)
    pre-commit run --all-files

CI

Add this to .pre-commit-config.yaml

ci:
    autofix_commit_msg: |
        [pre-commit.ci] auto fixes from pre-commit.com hooks

        for more information, see https://pre-commit.ci
    autofix_prs: true
    autoupdate_branch: ''
    autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
    autoupdate_schedule: weekly
    skip: []
    submodules: false

Hooks & Repos to use for more checks

Pre-commit
Interactive graph
On this page
Pre-commit
Husky
Add pre-commit to project
CI
Add this to .pre-commit-config.yaml
Hooks & Repos to use for more checks