git hook scripts

Brian J. Tarricone brian at tarricone.org
Sat May 9 23:43:49 CEST 2009


Uh, I think this is all a bit over-engineered.  Simpler, please.

	-b

On Sat, 9 May 2009 17:06:11 +0200 Jannis Pohlmann wrote:

> Hey,
> 
> 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;
> 
>   [xfcehooks]
>     mailinglist = xfce4-commits at xfce.org
>     envelopesender = true
>     gcobjects = 100
>     repoadmin = xfce4-dev at xfce.org
> 
> Hook scripts
> ============
> 
> I have a directory called $XFCE_GIT_HOOK_DIR with the following
> layout:
> 
>   ./hooks/update-01-block-invalid-updates
>   ./hooks/update-02-check-permissions
>   ./hooks/update-03-send-commit-mails
>   ./hooks/post-receive-01-update-docs
>   ./lib/init
>   ./update
>   ./post-receive
>   
> 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
>     fi
>   done
> 
> 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 and $XFCE_GIT_HOOK_EXCLUDE.
> 
> 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
> 
>      This will not set $XFCE_GIT_HOOK_INCLUDE/$XFCE_GIT_HOOK_EXCLUDE
>      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_EXCLUDE="update-03-send-commit-mails"
>        . $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
> 
>   http://git.xfce.org/jannis/xfce-git-hooks
> 
> 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



More information about the Xfce4-dev mailing list