I know that to make git check the commit message before committing you can implement hooks/commit-msg
. But now imagine a case where you want to let the hooks/pre-commit
script behave differently based on the commit message?
For example (in a very loose environment) you might want to check whether you have a [nocheck]
tag in your commit message which always lets your commit-check pass.
Or - in a more strict environment - you might want to have every file commented (and thus listed separately).
Or you might want to check the ticket ID against the related files.
etc...
Is there a way to accomplish this apart from doing the actual check in commit-msg (which seems to be counter-intuitive)?