I am looking for a configuration in the .pre-commit-config.yaml to exclude pre-commit from being run on certain branches, or to run it only on some branches. I don't know if this feature not implemented, or if I am missing it in the docs.
Thanks!
Git hooks are just shell scripts that are executed.
So in the script you can do something similar to this:
if [ $(git branch --no-color | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') = "main" ]; then
# Do checks for main here
fi
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