Fixed version
[invirt/packages/invirt-dev.git] / git-hooks / sub / zephyr-post-receive
index da91abe..3cb2086 100755 (executable)
@@ -14,6 +14,10 @@ instance=$(invirt-getconf "$base.instance" 2>/dev/null)
 zsig=$(invirt-getconf "$base.zsig" 2>/dev/null)
 color=$(invirt-getconf "$base.color" 2>/dev/null)
 
+# Git hooks are always called with PWD == GIT_DIR.
+repo=${PWD#/srv/git/}
+repo=${repo%/.git}
+
 if [ "${color:-true}" = "true" ]; then
     usecolor="--color"
 else
@@ -29,8 +33,8 @@ 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."
+    zwrite -c "$class" -i "$repo" -s "${zsig:-Git}: $refname" -d \
+      -m "New branch ${refname#refs/heads/} created."
     continue
   fi
   git rev-list --first-parent --reverse "$oldrev..$newrev" | while read rev; do
@@ -44,6 +48,6 @@ while read oldrev newrev refname; do
          -e 's/\e\[32m/@color(green)/g' \
          -e '1s/^/@{/' \
          -e '$s/$/}/') |
-    zwrite -c "$class" -i "${instance:-$shortrev}" -s "${zsig:-Git}: $refname" -d
+    zwrite -c "$class" -i "${instance:-$repo/$shortrev}" -s "${zsig:-Git}: $refname" -d
   done
 done