# F=hook_prop hook propagation in gitolite Some users like to know how hooks propagate, and when, and why there appear to be two places to put them, and so on. I'll try and set out the logic here. **Note**: You don't need to read all this just to add your own hooks or your own functionality to a hook that gitolite uses. See [here][customhooks] and [here][hookchaining]. ## what hooks do repos get? * `update`: all repos have this; it does the write-level access control (per-branch permissions). * `post-receive`: if you've enabled [mirroring][], all repos have this. * `post-update`: only the special "gitolite-admin" repo has this; it acts upon the changes you push to the admin repo. * `gitolite-hooked`: not really a hook, but a special, zero-byte file; see below. * you can add any other hooks you want (see note at the top of this doc), and gitolite will propagate them into all repos along with the others. ## when do repos "get" hooks? * When the "compile" script runs, any repo that is named explicitly in the conf file, and the "gitolite-hooked" file is not present, gets hooks. * When someone runs `gl-setup` on the server, then *all* repos physically present inside `$REPO_BASE` get them. A repo does not have to be defined in the config for this to happen. Also, this includes the initial install; if you already had some repos in `REPO_BASE` they get the hooks. * If `GL_WILDREPOS` is set, a repo gets hooks when a user creates a repo or uses the "fork" command in "contrib/adc". In the latter case the hooks are explicitly copied from the source repo using the "cp" command, not using the code internal to gitolite. ## what exactly does "get hooks" mean? The "hooks/" directory of the bare repo on the server will *forcibly* have symlinks created for each of the hooks mentioned in the "what hooks..." section. Other files are left alone, so you *can* manually add a hook file to specific repos, directly on the server, so long as there is no name clash. ## where do the symlinks point? There are two places the symlinks can point. * `$GL_PACKAGE_HOOKS/common` contains the "system" hooks. `GL_PACKAGE_HOOKS` is defined in the rc file. * `$HOME/.gitolite/hooks/common` has the "user" hooks. The special "post-update" hook for the equally special "gitolite-admin" repo is not in either of those places. It's in `../gitolite-admin` relative to them. Just don't worry about it, and don't fiddle with it. **There is no spoon**. `GL_PACKAGE_HOOKS` is "/var/gitolite/hooks" or some such path for RPM/DEB or "root" method, and "$HOME/share/gitolite/hooks" for the non-root method. (Basically, it's whatever you gave as the 3rd argument to 'gl-system-install' when you used the root or non-root methods, or whatever the packager decided if you used the RPM/DEB method). ## so where do I put my hooks? Put them in the "user" location (`~/.gitolite/hooks/common`). The "system" location hooks override the ones in the "user" location, as you can see from the picture below. This can be useful to enforce site-wide hooks when using the RPM/DEB or root install methods. (For the non-root install it's useless, since both locations are under the control of the user). .gv edge [dir=forward color="blue"] splines = false glph [ shape = none label = <
package/system hooks $GL_PACKAGE_HOOKS/common |
||
update | yourhook1 | yourhook2 |
user hooks ~/.gitolite/hooks/common |
||
update | yourhook1 | yourhook3 |
individual repo hooks $REPO_BASE/reponame.git/hooks |
|||
update | yourhook1 | yourhook2 | yourhook3 |