X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/blobdiff_plain/5661c3bc6c496f1cf9b6e4dd91216062a3b55445..514515d641ebe554482b0ae746cbb2ab8b64f7dc:/git-hooks/sub/zephyr-post-receive diff --git a/git-hooks/sub/zephyr-post-receive b/git-hooks/sub/zephyr-post-receive new file mode 100755 index 0000000..da91abe --- /dev/null +++ b/git-hooks/sub/zephyr-post-receive @@ -0,0 +1,49 @@ +#!/bin/sh +# +# This script is run after receive-pack has accepted a pack and the +# repository has been updated. It is passed arguments in through stdin +# in the form +# +# For example: +# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master + +base=build.hooks.post_commit.zephyr + +class=$(invirt-getconf "$base.class" 2>/dev/null) +instance=$(invirt-getconf "$base.instance" 2>/dev/null) +zsig=$(invirt-getconf "$base.zsig" 2>/dev/null) +color=$(invirt-getconf "$base.color" 2>/dev/null) + +if [ "${color:-true}" = "true" ]; then + usecolor="--color" +else + usecolor="" +fi + +if [ -z "$class" ]; then + echo "I don't know where to send a commit zephyr!" >&2 + echo "Please provide a value for $base.class in" >&2 + echo "your invirt config file." >&2 + exit 1 +fi +while read oldrev newrev refname; do + if [ "$oldrev" = "0000000000000000000000000000000000000000" ]; then + # dammit git + zwrite -c "$class" -i "$(basename "$refname")" -s "${zsig:-Git}: $refname" -d \ + -m "New branch created." + continue + fi + git rev-list --first-parent --reverse "$oldrev..$newrev" | while read rev; do + shortrev=`git log -1 --pretty=format:%h "$rev"` + (git show --stat -M $usecolor "$rev" | + sed -e 's/@/@@/g' \ + -e 's/}/@(})/g' \ + -e 's/\[m/}@{/g' \ + -e 's/\[33m/@color(yellow)/g' \ + -e 's/\[31m/@color(red)/g' \ + -e 's/\[32m/@color(green)/g' \ + -e '1s/^/@{/' \ + -e '$s/$/}/') | + zwrite -c "$class" -i "${instance:-$shortrev}" -s "${zsig:-Git}: $refname" -d + done +done