Create git server hooks which reject commits which do not pass the validation pipeline
We already have pre-commit hooks for both filehooks and gitsearch. Ideally, these should be used to validate changes before a commit happens. This keeps the commit history clean, since commits fail if an issue is found. As a reminder, the hooks can be installed as follows:
- filehooks:
pip install pre-commit && pre-commit install
(in the repo) - gitsearch:
npm install
(in the repo)
Server hooks are run when a git server receives a push from a client. For our use case, the update
hook is best suited, as it is invoked for each reference which is pushed (i.e. each branch, and a few other things like tags which can be skipped). Such a hook is an arbitrary script which can reject the changes on a branch by exiting non-zero. Messages can be sent to the user by printing on stdout.
Such a hook can prevent pushing commits to GitLab which do not pass validation. However, they do not prevent creating faulty commits, so they should not be the primary way of validation.