git hook scripts

Jannis Pohlmann jannis at
Sat May 9 17:06:11 CEST 2009


I'm currently fiddling with the hook scripts. I'd like to have a
directory where all our scripts are stored. To make the setup modular,
I'm currently using the following setup:

Repository configuration

Here I'm using a section called "xfcehooks". Every repository should
have it in its git config file, like this;

    mailinglist = xfce4-commits at
    envelopesender = true
    gcobjects = 100
    repoadmin = xfce4-dev at

Hook scripts

I have a directory called $XFCE_GIT_HOOK_DIR with the following

The ./hooks directory contains several hook scripts, each belonging to
one git hook (e.g. update or post-receive) and each serving exactly one
purpose (e.g. update-03-send-commit-mails *only* sends commit mails).
The numbers (01, 02, etc.) can be used to prioritize the scripts. For
the update hooks this means that if update-02-check-permissions fails,
the entire update fails and update-03-send-commit-mails is not executed.

The ./lib directory contains commonly required functions, all of them
made available by importing the ./lib/init script.

The toplevel scripts (here: ./update and ./post-receive) are what we
link to from the hooks directory of each repository. They import
./lib/init and execute the ./hook scripts in prioritized order.
This is how the update script currently looks like:

  # Initialize the hook script
  . $XFCE_GIT_HOOK_DIR/lib/init

  for script in $XFCE_GIT_HOOK_DIR/hooks/update-*; do
    if ! xfce_git_hook_is_excluded `basename $script`; then
      $script $* || exit 1

xfce_git_hook_is_excluded() uses two environment variables to find out
whether a hook script should be executed or not: $XFCE_GIT_HOOK_INCLUDE

How to use the scripts

There are two possiblities:

  1) Directly link to the toplevel hooks, e.g. in a repository:
       ln -s $XFCE_GIT_HOOK_DIR/update hooks/update

     and will thus execute *all* hooks.

  2) Create a script that sets $XFCE_GIT_HOOK_INCLUDE/EXCLUDE and calls
     the toplevel hook. E.g. for all private repositories, do
     something like this:

       . $XFCE_GIT_HOOK_DIR/update

I'm currently thinking about how to exclude certain scripts by default,
like the update docs script. I've created a repository

in which I'll work on the hooks. We can import them into Brian's git
migration repository at a later stage, I guess.

  - Jannis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <>

More information about the Xfce4-dev mailing list