pre-commit¶
Python tool for managing git pre-commit hooks
-
https://pre-commit.com/
- Run on a commit that's already committed:
pre-commit run --from-ref HEAD~1 --to-ref HEAD
Usage¶
Install pre-commit into your repo's git hooks¶
- Do this whenever on any checked out repo where you want pre-commit to run on every commit.
Run manually:
Output from failing git commit:
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - -S
check for added large files..............................................Passed
Markdown Link Check......................................................Failed
- hook id: markdown-link-check
- exit code: 1
ERROR: 1 dead links found in personal/Daily/2024-01/2024-01-30-Tue.md !
[✖] ../tasks/summary.md → Status: 400
Install¶
Shell completion script: Takishima/pre-commit-completion Bash completion for pre-commit with hook id completion provided based on the rapidyaml
, c4core
and c4fs
libraries (github.com)
Configure¶
Add .pre-commit-config.yaml to git repo¶
Setup the git hook scripts¶
Lock external hooks to a specific version (git sha) with:¶
Testing¶
Resources¶
Hooks¶
Notes from aider¶
Pre-commit Hooks¶
The project uses pre-commit hooks to automatically format code, lint, and run other checks before committing changes. After cloning the repository, run the following command to set up the pre-commit hooks:
pre-commit will then run automatically on each git commit
command. You can use the following command line to run pre-commit manually: