#!/usr/bin/env rc fn usage { echo usage: sip-install-hooks.rc REPO >[1=2] exit 2 } if(! ~ $#* 1) usage repo=$1 if(! git -C $repo rev-parse --git-dir >/dev/null >[2=1]) usage scriptdir=`{dirname $0} root=`{cd $scriptdir^/..; pwd} gitdir=`{git -C $repo rev-parse --git-dir} if(! ~ $gitdir /*) #*/ gitdir=$repo^/$gitdir hookdir=$gitdir^/hooks mkdir -p $hookdir cp $root^/hooks/pre-receive.rc $hookdir^/pre-receive awk -v root=$root '{ gsub("@SIP_ROOT@", root); print }' $root^/hooks/post-receive.rc >$hookdir^/post-receive chmod +x $hookdir^/pre-receive $hookdir^/post-receive echo installed sip hooks in $hookdir