Automating Git with hooks
There are usually certain prerequisites to the code that is produced, either self-induced or enforced externally. The code should be always able to compile and pass at least a fast subset of the tests. With some development workflows, each commit message may need to reference an issue ID (or fit message template), or include a digital certificate of origin in the form of the Signed-off-by
line. In many cases, these parts of the development process can be automated by Git.
Like many programming tools, Git includes a way to fire custom functionality contained in the user-provided code (custom scripts), when certain important pre-defined actions occur, that is, when certain events trigger. Such a functionality invoked as a event handler is called a hook. It allows to take an additional action and, at least for some hooks, also to stop the triggered functionality.
Hooks in Git can be divided into the client-side and the server-side hooks. Client-side hooks are triggered...