]> sipb.mit.edu Git - snippets/.git/blobdiff - git-hooks/zephyr-post-receive
Update the git post-receive hook for git's new default description.
[snippets/.git] / git-hooks / zephyr-post-receive
index 19260d7bd1de7afe682699fc35ebcfaa2618ba37..71e96bccad9f2e057d733eef73bc687d58a21ca6 100755 (executable)
@@ -18,6 +18,20 @@ else
     usecolor=""
 fi
 
+if [ -z "$zsig" ]; then
+    if [ -e "$GIT_DIR/description" ]; then
+        zsig=`cat "$GIT_DIR/description"`
+    fi
+    if [ -z "$zsig" ] || \
+        [ "$zsig" = "Unnamed repository; edit this file to name it for gitweb." ] || \
+        [ "$zsig" = "Unnamed repository; edit this file 'description' to name the repository." ]; then
+        zsig=$(basename "$(readlink -f "$GIT_DIR")")
+        if [ "$zsig" = ".git" ]; then
+            zsig=$(basename "$(readlink -f "$GIT_DIR/..")")
+        fi
+    fi
+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
@@ -25,14 +39,23 @@ if [ -z "$class" ]; then
   exit 1
 fi
 while read oldrev newrev refname; do
-  git-rev-list --reverse "$oldrev..$newrev" | while read rev; do
+  if [ "$oldrev" = "0000000000000000000000000000000000000000" ]; then
+    # dammit git
+    zwrite -c "$class" -i "${instance:-${refname#refs/heads/}}" -s "$zsig: $refname" -d \
+      -m "New branch $refname created, currently at $newrev."
+    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 $usecolor "$rev" |
-     sed "s/@/@@/g" |
-     sed "s/\e\[m/@color(default)/g" |
-     sed "s/\e\[33m/@color(yellow)/g" |
-     sed "s/\e\[31m/@color(red)/g" |
-     sed "s/\e\[32m/@color(green)/g") |
-    zwrite -c "$class" -i "${instance:-$shortrev}" -s "${zsig:-Git}: $refname" -d
+    (git show --stat -M $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: $refname" -d
   done
 done