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