From ecd6ec9bce116f2f0cf40266db406dd748ed45e1 Mon Sep 17 00:00:00 2001 From: Neil Muller Date: Mon, 9 Mar 2020 15:06:27 +0200 Subject: [PATCH] Add irker hook --- irker | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 irker diff --git a/irker b/irker new file mode 100755 index 0000000..ab0b10a --- /dev/null +++ b/irker @@ -0,0 +1,50 @@ +#!/bin/bash + +IRKERPATH=/home/irker/VE/bin/ + +function help() { + echo "Required config settings:" + echo " git config irker.channels 'channel1 channel2 ..'" + echo " git config irker.project 'Project name'" + echo " git config irker.server 'server'" + echo " git config irker.server 'server'" +} + + +function notify_irker() { + old=$1 + new=$2 + refname=$3 + + if [ "x$old" = "x0000000000000000000000000000000000000000" ]; then + # We're pushing into an empty repo, so we need a different command + # to get the rev list + # This does the wrong thing if the parent of the branch isn't master + # but it is kind of correct most of the time + ${IRKERPATH}/irkerhook.py --refname=${refname} \ + $(git rev-list $new --not master) + elif [ "x$new" = "x0000000000000000000000000000000000000000" ]; then + # We're deleting a branch - we need to do the right thing + # (whatever that is) + # This is not the right thing, but will do for now + repo=$(basename $PWD | sed 's/.git$//' ) + for channel in $(git config --get irker.channels | sed "s/,/ /"); do + ${IRKERPATH}/irk $channel "$repo: Deleted branch $refname" + done + else + ${IRKERPATH}/irkerhook.py --refname=${refname} \ + $(git rev-list --reverse ${old}..${new}) + fi +} + +channels=$(git config --get irker.channels) + +while read line; do + set -- $line + if [ -n "$channels" ]; then + notify_irker $* + fi + RET=$? +done + +exit $RET -- 2.34.1