Commit f0d18eb0 authored by Robert Ricci's avatar Robert Ricci

New git utility script: git-multihook

Allows you to call more than one hook - eg. to use git-checkout-push
and gitmail both from post-receive
parent 09eecec3
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2011 University of Utah and the Flux Group.
# All rights reserved.
#
#
# Script to allow more than one hook script to be called from a single git
# hook.
#
# To set up, set the config variables:
# git config --add hooks.multihook.<hookname> <script>
# ... where <hookname> is the name of the hook that is being called (eg.
# 'post-receive'), and <script> is the other hook script you want to call.
# It's a good idea to give the full path to this script.
#
# You can run this command more than once to cause more than one other script
# to get called.
#
my $GIT = "git";
my $CONFIGBASE = "hooks.multihook";
#
# Figure out which hook we are being called as
#
my $whichhook = `basename '$0'`;
chomp($whichhook);
my $configvar = $CONFIGBASE . "." . $whichhook;
#
# Figure out which other scripts we are supposed to call
# (Note that, for now, we don't support running them in any order other than
# the one that 'git config' happens to return.)
#
my @scripts = `$GIT config --get-all $configvar`;
chomp @scripts;
if (!@scripts) {
print "*** WARNING: git-multihook in use, but $configvar is empty\n";
exit;
}
#
# Simply read in the stuff we were passed on STDIN, we'll pass it to the other
# scripts we call
#
my @inputlines = <STDIN>;
#
# No real error checking for now.
#
foreach my $script (@scripts) {
open(SCRIPT,"| $script");
print SCRIPT @inputlines;
close(SCRIPT);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment