Git Commit Hooks

Pre-commit

Runs before a commit. This is useful to verify that the commit message follows the correct format. It can also be used to regenerate files before committing.

See for example the landdown pre-commit hook which regenerates the readme page before committing.

Post-receive

Useful to trigger CI pipelines. See for example Git Repo Tutorial.

Pre-receive

Useful to restrict access to a repository. Can be used to set up protected branches or protected files.

Post-commit

Useful if you want to have tests run in the background locally. See Local Test CI Using Git Hooks and Notes.

Sendemail-validate

Great place to run tests and fail early, so the submitter can quickly catch mistakes without you needing to apply the patch and run all the tests. You probably still want the user to be able to send their patch though even if tests fail.

One implementation could include the test results as part of the patch. An alternative approach could prompt the user, asking if they want to send the email patch even if the tests are failing.