Is there already a pre-commit.com hook to reject commit if a file contains a specific string?
I know how to do this with a git pre-commit hook: https://stackoverflow.com/a/26836281/633961
But I would like to go the pre-commit.com way because this would streamline my way to a way which is done by other developers.
For example I would like to use the same string which other people use, too.
The easiest way is to use a language: pygrep hook. This implements a regex matching againsta file
pygrep is especially useful for a repo: local hook which lives directly in your repository's .pre-commit-config.yaml file
an example which forbids DONTSHIP:
- repo: local
hooks:
- id: dontship
name: DONTSHIP check
entry: DONTSHIP
language: pygrep
types: [text]
disclaimer: I'm the creator of pre-commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With