This repository provides a set of Git hooks that enforce quality checks and best practices on commits.
This repository is designed to be used as a Git submodule in other projects, specifically the nullpunk repository (although this is not a requirement). When integrated, it automatically configures Git hooks for the repository to follow certain rules and checks.
The key files in this repository are located under the hooks/
directory.
Each script has a special name that Git knows.
A full list of them can be found there Git Hook.
The setup-hooks script configures Git to use the hooks from this directory,
ensuring that any action made within the repository is checked according to the rules.
The script also configures Git to look for hooks in the qa/hooks/
directory instead of the default .git/hooks/
.
This depends on the value of the config_type
variable at the start of the setup-hooks script.
The scripts are also made executable, so that Git can actually work with them.
Git triggers each hook automatically, depending on the performed action.
The hooks in this repository are modular, so they can be easily extended as needed for other Git actions, like
pre-commit, post-commit, pre-push, etc. The scripts in the hooks/
directory can be added/modified, and they will
automatically be used by Git during the corresponding Git action.
This setup results in roughly this architecture:
- The setup-hooks script configures Git and the hooks
- The
hooks/
directory contains scripts that Git automatically executes, depending on the performed action, and the name of the script - Each script in the
hooks/
directory contains logic specific to the action the file name correlates to - The other scripts under the
utils/
directory contain separated and self-contained logic that can be reused where needed
As this repository is intended to be used as a submodule, it needs to be updated in all other repositories that use this repository.
The first thing you need to do is create a .zflsb
file, otherwise default values will be used.
The .zflbs
file should contain the following config:
GITHUB_ORG=<your-org-name>
GITHUB_REPO=<your-repo-name>
After that you need to set the config variable config_type
in the setup-hooks
script. The value has to be repository
. This can be done when running the script, meaning you can use
./scripts/setup-hooks repository
, if you are running the script from the repository root, otherwise change the path
accordingly.
See contributing As for naming things, we are following Google's conventions document.