stub git hooks: for now, they zephyr
authorGreg Price <price@mit.edu>
Sat, 2 May 2009 22:53:51 +0000 (18:53 -0400)
committerGreg Price <price@mit.edu>
Sat, 2 May 2009 22:53:51 +0000 (18:53 -0400)
svn path=/trunk/scripts/git-hooks/; revision=2323

post-receive.sub [new file with mode: 0644]
post-receive.super [new file with mode: 0644]
zephyr-post-receive [new file with mode: 0755]

diff --git a/post-receive.sub b/post-receive.sub
new file mode 100644 (file)
index 0000000..e6987f1
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+file=`mktemp -t git-receive.XXXXXX` || exit $?
+cat >$file
+
+"$PWD"/hooks/zephyr-post-receive <$file
+
+rm -f $file
diff --git a/post-receive.super b/post-receive.super
new file mode 100644 (file)
index 0000000..e6987f1
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+file=`mktemp -t git-receive.XXXXXX` || exit $?
+cat >$file
+
+"$PWD"/hooks/zephyr-post-receive <$file
+
+rm -f $file
diff --git a/zephyr-post-receive b/zephyr-post-receive
new file mode 100755 (executable)
index 0000000..7e06b30
--- /dev/null
@@ -0,0 +1,41 @@
+#!/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
+#  <oldrev> <newrev> <refname>
+# For example:
+#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
+
+class=`git config zephyr.class`
+instance=`git config zephyr.instance`
+zsig=`git config zephyr.zsig`
+color=`git config --bool zephyr.color`
+
+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 set the zephyr.class config variable in" >&2
+  echo "$PWD/config." >&2
+  exit 1
+fi
+while read oldrev newrev refname; do
+  git-rev-list --reverse "$oldrev..$newrev" | while read rev; do
+    shortrev=`git log -1 --pretty=format:%h "$rev"`
+    (git show --stat $usecolor "$rev" |
+     sed -e 's/@/@@/g' \
+         -e 's/}/@(})/g' \
+         -e 's/\e\[m/}@{/g' \
+         -e 's/\e\[33m/@color(yellow)/g' \
+         -e 's/\e\[31m/@color(red)/g' \
+         -e 's/\e\[32m/@color(green)/g' \
+         -e '1s/^/@{/' \
+         -e '$s/$/}/') |
+    zwrite -c "$class" -i "${instance:-$shortrev}" -s "${zsig:-Git}: $refname" -d
+  done
+done