From 4c1743b28a318e14547058295651dc33bb98473e Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 10 Mar 2018 11:58:10 -0800 Subject: [PATCH] Notify.pm: export GIROCCO_BASEDIR for girocco.notifyhook When running a custom notify hook (either via a direct girocco.notifyhook project-specific setting or the global $Girocco::Config::default_notifyhook setting), the hook may want to make use of some of the Girocco facilities and/or configuration values while going about its business. Standard Girocco hooks/scripts/etc. go about this by using the value of $Girocco::Config::basedir that was substituted into them during the install process. Provide that same value via the GIROCCO_BASEDIR environment variable so the custom notify hook can do the same if it so desires. Shell scripts can then do either this: . "$GIROCCO_BASEDIR/shlib.sh" or to just get the config settings this: . "$GIROCCO_BASEDIR/shlib_vars.sh" Perl scripts can do this: use lib $ENV{GIROCCO_BASEDIR"; and then "use" the appropriate module(s) such as "Girocco::Config". Other languages can easily parse the format of the shlib_vars.sh file to extract the values as it's a simple line-oriented name=value format where value either contains no whitespace or double-quotes at all or immediately starts with a double-quote using exactly 4 possible escapes ( \\ \` \$ \" ) before ending with another double-quote (embedded newlines ARE allowed in the double-quoted value case). Signed-off-by: Kyle J. McKay --- Girocco/Notify.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Girocco/Notify.pm b/Girocco/Notify.pm index 421fc5c..dc96d2e 100644 --- a/Girocco/Notify.pm +++ b/Girocco/Notify.pm @@ -318,6 +318,7 @@ sub ref_changes { # * the PATH is guaranteed to find the correct Git, utils and $basedir/bin # * the hook need not consume all (or any) of stdin # * the exit code for the hook is ignored (just like Git's post-receive) + # * the GIROCCO_BASEDIR environment variable is set to $Girocco::Config::basedir my $customhook; if (($customhook = $proj->_has_notifyhook)) {{ my @argv = (); @@ -341,6 +342,7 @@ sub ref_changes { push(@same, [$same{$_}, $same{$_}, $_]) foreach sort keys %same; push(@argv, @same + @mod, @same + 0); chdir($proj->{path}) or last; + local $ENV{GIROCCO_BASEDIR} = $Girocco::Config::basedir; local $ENV{PATH} = util_path; if (open my $hookpipe, '|-', @argv) { local $SIG{'PIPE'} = sub {}; -- 2.11.4.GIT