Skip to content

Pre commit notes

Joris Roovers edited this page Nov 11, 2022 · 6 revisions

To install/try it with gitlint:

tools/create-test-repo.sh
cd <new test repo>
virtualenv .venv && source .venv/bin/activate
pip install pre-commit
echo "\
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.2.3
    hooks:
    -   id: trailing-whitespace
-   repo: https://github.com/jorisroovers/gitlint
    rev:  v0.17.0
    hooks:
    -   id: gitlint
" > .pre-commit-config.yaml && cat .pre-commit-config.yaml
pre-commit install
pre-commit install --hook-type commit-msg

# To run hooks
pre-commit run
pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG

In the background, precommit will download your repo to ~/.cache/pre-commit/<randomname>/...

# To try something out (i.e. different gitlint invocation)
# Edit pre-commit file (not that actual repo name can change
vim  ~/.cache/pre-commit/repovpt2sdmn/.pre-commit-hooks.yaml