Running Custom Hooks in Gitolite3

Sometimes you need to use hooks, but hooks are configured individually for each repository. Sometimes, however, you need a shared hook for all specified repositories. This can also be done using Gitolite3.
Configuring the local gitolite.conf
Open the file conf/gitolite.conf in the gitolite-admin repository for editing and specify which repositories (all of them in our example) and which users the hook should be invoked for:
repo @all
- VREF/my_hook = @all
Configuring .gitolite.rc on the server
Log in to the server and open the file ~/.gitolite.rc for editing, find the line LOCAL_CODE and uncomment it:
# this one is managed directly on the server
LOCAL_CODE => "$ENV{HOME}/local",
Create a hook script, for example with the following contents, and place it at ~/local/VREF/my_hook:
#!/bin/sh
if [ $GL_REPO != "gitolite-admin" ]; then
echo "-----------------------------------------------------------"
echo "You repository here: https://git.example.org/$GL_REPO/"
echo "-----------------------------------------------------------"
fi
For Gitolite to pick up your changes, you need to recompile it:gitolite compile
Comments are closed. Read the original discussion in Russian →