[vcsh] hook system for vcsh

Vincent Demeester vincent at demeester.fr
Mon Jan 9 11:55:49 CET 2012


Hi,

> vdemeester wrote:
>> Only the ones that have an executable bit will be sourced.
> setting executable flag to make it become sourced seems weird.
> especially because +x is not even needed if it's sourced.
> i would say merely the fact that a file is stored within
> $XDG_CONFIG_HOME/vcsh/hook.d/init/ qualifies it as a hook. nothing 
> more
> is needed. no +x flag.
I did this to be able to write non-active hook (example hook or no more
active ones but that I'd like to keep for… posterity :-p).
Git hooks are only active when the x bits are on (but they might be 
called,
not sourced).

> RichiH wrote:
>> What if you need to run a hook for zsh, only?
> inside the hook file, you can do logic like:
> if [ "$VCSH_REPO_NAME" = "vcsh" ]; then... fi
> the fact that hooks are sourced (vs executed) is very powerful, it
> gives the hook access to everything going on within vcsh. (all vars,
> all defined functions, etc)
I didn't thought about using $VCSH_REPO_NAME for repo-specific hooks 
but
yes that's the power of sourcing hooks.

> vdemeester wrote:
>> For example if I want foo and bar hook for the init hook :
>> With git hook approach, you would have to source foo and bar in the
>> $VCSH_HOOK_D/init file.
>
> what are foo and bar? different files, so the $VCSH_HOOK_D/init file
> sources those 2 files?
In both example, foo and bar are files (shell script). In the git hook
approach you have to source them from $VCSH_HOOK_D/init (which is 
sourced
by vcsh), and on the other approach, they'll be auto-magically sourced.

In my opinion, the git approach for hooks might be cleaner and simpler.

Vincent (a.k.a vdemeester)


More information about the vcs-home mailing list