3 # This script is run after receive-pack has accepted a pack and the
4 # repository has been updated. It is passed arguments in through stdin
6 # <oldrev> <newrev> <refname>
8 # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
10 base=build.hooks.post_commit.zephyr
12 class=$(invirt-getconf "$base.class" 2>/dev/null)
13 instance=$(invirt-getconf "$base.instance" 2>/dev/null)
14 zsig=$(invirt-getconf "$base.zsig" 2>/dev/null)
15 color=$(invirt-getconf "$base.color" 2>/dev/null)
16 maxlines=`git config --int zephyr.maxlines 2>/dev/null || echo 50`
18 # Git hooks are always called with PWD == GIT_DIR.
22 if [ "${color:-true}" = "true" ]; then
28 if [ -z "$zsig" ]; then
29 if [ -e "$GIT_DIR/description" ]; then
30 zsig=`cat "$GIT_DIR/description"`
32 if [ -z "$zsig" ] || \
33 [ "$zsig" = "Unnamed repository; edit this file to name it for gitweb." ] || \
34 [ "$zsig" = "Unnamed repository; edit this file 'description' to name the repository." ]; then
35 zsig=$(basename "$(cd "$GIT_DIR" && pwd)")
36 if [ "$zsig" = ".git" ]; then
37 zsig=$(basename "$(cd "$GIT_DIR/.." && pwd)")
42 if [ -z "$class" ]; then
43 echo "I don't know where to send a commit zephyr!" >&2
44 echo "Please provide a value for $base.class in" >&2
45 echo "your invirt config file." >&2
52 zwrite -c "$class" -i "${instance:-git}" -s "Aperture Science Emergency Intelligence Incinerator" -d \
53 -m 'Aborting zephyr hook to prevent zwrite flood.'
58 while read oldrev newrev refname; do
59 if [ "$oldrev" = "0000000000000000000000000000000000000000" ]; then
62 zwrite -c "$class" -i "$repo" -s "${zsig:-Git}: $refname" -d \
63 -m "New branch ${refname#refs/heads/} created, currently at $newrev."
68 shortrev=`git log -1 --pretty=format:%h "$rev"`
69 lines=`git show -M "$rev" | wc -l`
70 if [ $lines -lt $maxlines ]; then
75 (git show -M $stat $usecolor "$rev" |
79 -e 's/
\e\[1m/}@b{/g' \
80 -e 's/
\e\[33m/@color(yellow)/g' \
81 -e 's/
\e\[31m/@color(red)/g' \
82 -e 's/
\e\[32m/@color(green)/g' \
83 -e 's/
\e\[36m/@color(cyan)/g' \
86 zwrite -c "$class" -i "${instance:-$repo/$shortrev}" -s "${zsig:-Git}: $refname" -d
87 done < <(git rev-list --first-parent --reverse "$oldrev..$newrev")