Expanding on my fragmented git hooks_

July 10, 2019 @16:00

Hooks are a great way to execute various tasks as part of your git(1) workflow. Since I run my own repository server I have plugged a number of different things into my repositories, both private and public. There are several previous posts where I discuss some of them.

git push output

To access my git repository there are in general 3 methods. I allow anonymous pulls via https using the built in HTTP helpers with Apache, authenticated pulls and pushes use ssh and gitolite, and finally there is both a public and private viewer using gitweb. The latter most automatically includes the contents of README.html in the root of the repository in the header of the project pages on the rendered website. I almost never remember to update it, so I set about writing a hook to take care of it for me. Since I have a bunch of hooks already I also added a way to have several hooks all get run from the main hook.

My git server's root is /srv/git, the repositories are in /srv/git/repositories, so I put my global post-receive hook in /srv/git/repositiories/global-hooks/. In all the different repositories where I already had a post-receive hook I created a hooks/post-receive.d/ directory and moved the hook into it with a descriptive name. For example the hook on my misc.git repository that creates the checksum file used by my .profile auto-updater is now called post-receive.d/checksum. I then wrote a small script to link the global hook into all my repositories.

If you are interested you can find the hook and the install script in my misc git repository.

Subscribe via RSS. Send me a comment.