git hooks1 - ghdrako/doc_snipets GitHub Wiki
- The official documentation on Git hooks
- git-toolbelt – A collection of convenient utilities for everyday git usage
- https://github.com/adnanh/webhook
- https://gitbetter.substack.com/p/automate-repetitive-tasks-with-custom
- https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
Each of the hooks can be bypassed by calling its git command with the --no-verify option.
All the features are disabled by default, and each on can be enabled and configured by setting some environment variables (GIT_GRAPNEL_*).
pre-commit
This hook is run whenever committing to a repo.
Setting GIT_GRAPNEL_LINT_ON_COMMIT
to 1 will enable the automatic linting of modified source files. The commit will be cancelled if any errors or warnings are produced.
commit-msg
This hook is run whenever committing to a repo.
Setting GIT_GRAPNEL_COMMIT_MSG_FORMAT
to one of the following values will enforce that particular format for commit message:
- basic: the message must start with a capital letter and not end with a full stop
- conventional-commits: the message must conform to the Conventional Commits specification
It can also:
- spellcheck the commit message and highlight possible typos (
GIT_GRAPNEL_SPELLCHECK
) - convert pairs of single quotes ('') into a single back quote — useful when you surround the message in double quotes on the command line (
GIT_GRAPNEL_CONVERT_SINGLE_QUOTE_PAIRS
) - automatically add a corresponding emoji at the start of Conventional Commits messages (
GIT_GRAPNEL_ADD_EMOJIS
)
pre-push
This hook is run whenever pushing to a remote.
Setting GIT_GRAPNEL_PRE_PUSH_CHECKS
to 1 will automatically lint the codebase and run the testing scripts present in package.json, and abort the push if any of them fail.
post-merge
This hook is run after a successful merge.
Setting GIT_GRAPNEL_AUTO_INSTALL
to 1 will reinstall the Node modules as needed to keep them in sync with package-lock.json.