source: trunk/packages/invirt-dev/git-hooks/sub/zephyr-post-receive @ 3040

Last change on this file since 3040 was 3038, checked in by gdb, 14 years ago

Added git hooks to invirt-dev package

  • Property svn:executable set to *
File size: 1.6 KB
RevLine 
[3038]1#!/bin/sh
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
10base=build.hooks.post_commit.zephyr
11
12class=$(invirt-getconf "$base.class" 2>/dev/null)
13instance=$(invirt-getconf "$base.instance" 2>/dev/null)
14zsig=$(invirt-getconf "$base.zsig" 2>/dev/null)
15color=$(invirt-getconf "$base.color" 2>/dev/null)
16
17if [ "${color:-true}" = "true" ]; then
18    usecolor="--color"
19else
20    usecolor=""
21fi
22
23if [ -z "$class" ]; then
24  echo "I don't know where to send a commit zephyr!" >&2
25  echo "Please provide a value for $base.class in" >&2
26  echo "your invirt config file." >&2
27  exit 1
28fi
29while read oldrev newrev refname; do
30  if [ "$oldrev" = "0000000000000000000000000000000000000000" ]; then
31    # dammit git
32    zwrite -c "$class" -i "$(basename "$refname")" -s "${zsig:-Git}: $refname" -d \
33      -m "New branch created."
34    continue
35  fi
36  git rev-list --first-parent --reverse "$oldrev..$newrev" | while read rev; do
37    shortrev=`git log -1 --pretty=format:%h "$rev"`
38    (git show --stat -M $usecolor "$rev" |
39     sed -e 's/@/@@/g' \
40         -e 's/}/@(})/g' \
41         -e 's/\[m/}@{/g' \
42         -e 's/\[33m/@color(yellow)/g' \
43         -e 's/\[31m/@color(red)/g' \
44         -e 's/\[32m/@color(green)/g' \
45         -e '1s/^/@{/' \
46         -e '$s/$/}/') |
47    zwrite -c "$class" -i "${instance:-$shortrev}" -s "${zsig:-Git}: $refname" -d
48  done
49done
Note: See TracBrowser for help on using the repository browser.