]>
Commit | Line | Data |
---|---|---|
efdbeff7 | 1 | #!/bin/bash |
5b11b497 GT |
2 | # |
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 | |
5 | # in the form | |
6 | # <oldrev> <newrev> <refname> | |
7 | # For example: | |
8 | # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master | |
9 | ||
10 | class=`git config zephyr.class` | |
916beed8 | 11 | instance=`git config zephyr.instance` |
5b11b497 | 12 | zsig=`git config zephyr.zsig` |
aa39c04d | 13 | color=`git config --bool zephyr.color` |
64786cec | 14 | maxlines=`git config --int zephyr.maxlines 2>/dev/null || echo 50` |
aa39c04d NE |
15 | |
16 | if [ "${color:-true}" = "true" ]; then | |
17 | usecolor="--color" | |
18 | else | |
19 | usecolor="" | |
20 | fi | |
21 | ||
b0d563fe GT |
22 | if [ -z "$zsig" ]; then |
23 | if [ -e "$GIT_DIR/description" ]; then | |
24 | zsig=`cat "$GIT_DIR/description"` | |
25 | fi | |
fe93b4bc EB |
26 | if [ -z "$zsig" ] || \ |
27 | [ "$zsig" = "Unnamed repository; edit this file to name it for gitweb." ] || \ | |
28 | [ "$zsig" = "Unnamed repository; edit this file 'description' to name the repository." ]; then | |
efdbeff7 | 29 | zsig=$(basename "$(cd "$GIT_DIR" && pwd)") |
b0d563fe | 30 | if [ "$zsig" = ".git" ]; then |
efdbeff7 | 31 | zsig=$(basename "$(cd "$GIT_DIR/.." && pwd)") |
b0d563fe GT |
32 | fi |
33 | fi | |
34 | fi | |
35 | ||
5b11b497 GT |
36 | if [ -z "$class" ]; then |
37 | echo "I don't know where to send a commit zephyr!" >&2 | |
38 | echo "Please set the zephyr.class config variable in" >&2 | |
39 | echo "$PWD/config." >&2 | |
40 | exit 1 | |
41 | fi | |
72b08995 AK |
42 | |
43 | let max=10 | |
44 | check_max () { | |
45 | if ! let --max; then | |
46 | zwrite -c "$class" -i "${instance:-git}" -s "Aperture Science Emergency Intelligence Incinerator" -d \ | |
47 | -m 'Aborting zephyr hook to prevent zwrite flood.' | |
48 | exit 0 | |
49 | fi | |
50 | } | |
51 | ||
5b11b497 | 52 | while read oldrev newrev refname; do |
d0ef17b3 | 53 | if [ "$oldrev" = "0000000000000000000000000000000000000000" ]; then |
72b08995 | 54 | check_max |
d0ef17b3 | 55 | # dammit git |
a4574a07 | 56 | zwrite -c "$class" -i "${instance:-${refname#refs/heads/}}" -s "$zsig: $refname" -d \ |
210a5c8a | 57 | -m "New branch $refname created, currently at $newrev." |
d0ef17b3 GT |
58 | continue |
59 | fi | |
72b08995 AK |
60 | while read rev; do |
61 | check_max | |
5b11b497 | 62 | shortrev=`git log -1 --pretty=format:%h "$rev"` |
64786cec | 63 | lines=`git show -M "$rev" | wc -l` |
64786cec | 64 | if [ $lines -lt $maxlines ]; then |
0a6422ec AD |
65 | stat="" |
66 | else | |
67 | stat="--stat" | |
64786cec | 68 | fi |
0a6422ec | 69 | (git show -M $stat $usecolor "$rev" | |
5dceef3e AK |
70 | sed -e 's/@/@@/g' \ |
71 | -e 's/}/@(})/g' \ | |
72 | -e 's/\e\[m/}@{/g' \ | |
0a6422ec | 73 | -e 's/\e\[1m/}@b{/g' \ |
5dceef3e AK |
74 | -e 's/\e\[33m/@color(yellow)/g' \ |
75 | -e 's/\e\[31m/@color(red)/g' \ | |
76 | -e 's/\e\[32m/@color(green)/g' \ | |
64786cec | 77 | -e 's/\e\[36m/@color(cyan)/g' \ |
5dceef3e AK |
78 | -e '1s/^/@{/' \ |
79 | -e '$s/$/}/') | | |
b0d563fe | 80 | zwrite -c "$class" -i "${instance:-$shortrev}" -s "$zsig: $refname" -d |
72b08995 | 81 | done < <(git rev-list --first-parent --reverse "$oldrev..$newrev") |
5b11b497 | 82 | done |