Ad

How To Identify If A Git Commit Skipped Pre-hook Checks Or Not?

- 1 answer

We have set of predefined pre-hooks which checks for code validation and runs commit message enforcers and some-other things, but people tend to skip this validations by running git commit -n.

Is there way to identify those commits which skipped pre-hooks ? Or can we add some metadata to each commit with pre-hooks passed or pre-hooks failed ?

Thanks,

Ad

Answer

The only way to do this would be using a server side hook or in a CI job.

If you use the tool pre-commit, you can use this CI job template to automatically check pre-commit hooks and, optionally, automatically apply automatic fixes to the source branch from the CI job.

For GitHub.com users, there's also pre-commit.ci.

Ad
source: stackoverflow.com
Ad