pre-commit¶
- Website
- GitHub
-
2k commits, 13k ⭐
- Supported hooks
- Cached hooks:
~/.cache/pre-commit - Custom hooks (see below):
~/projects/git/pre-commit/pre-commit-config-varac
Install:
Usage:
pre-commit sample-config > .pre-commit-config.yaml
pre-commit install
pre-commit run --all-files
pre-commit run --all-files --show-diff-on-failure
Skip hooks:
General hooks¶
Good documentation including expected stdin/parameters
Global hooks activated by:
Filtering files with types¶
Identify file type discovered by pre-commit:
Issues¶
Global hooks / include statement¶
- Ability to include additional hooks
- Doesn't work well together with global hooks
- Global hook to detect pre-commit config per repo and run if present
- Metahooks / nested config
- How can I configure pre-commit globally for all projects?
- Support global git hooks in git v2.9
Workarounds:
Integrations / plugins / shared hooks¶
Ansible¶
Chef¶
https://github.com/mattlqx/pre-commit-ruby
YAML¶
Docker¶
Kubernetes¶
Kubeval:
- Using k8validate doesn't work
Gitlab Ci Linter¶
See ../gitlab/ci.md
Check for secret material¶
see security/passwords/linting.md
gitmoji¶
https://gitmoji.carloscuesta.me/ https://hackernoon.com/using-github-as-a-team-the-holy-grail-of-commit-messages-f5b10c925d62
pre-commit in CI¶
to-be-continuous/pre-commit¶
- Gitlab
- Beware:
- ignores the default .pre-commit-config.yaml file
- runs the pre-commit command with a sanitized list of pre-commit checks we think many teams can agree to implement as a sensible baseline.
Container images¶
Gitlab CI Templates¶
- yesolutions/gitlab-ci-templates: pre-commit-autofix
- Last commit 2022
- Container image: yesolutions/docker-pre-commit:
- Last commit also 2022