rboyd / git2yammer

a post-receive hook to relay git commits to yammer

This URL has Read+Write access

git2yammer / post-receive-yammer
100755 36 lines (31 sloc) 1.006 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# most of this code shamelessly ripped from Andy Parkins' post-receive-email script
 
generate_yammer()
{
oldrev=$(git rev-parse $1)
newrev=$(git rev-parse $2)
refname="$3"
/usr/bin/ruby git2yammer.rb $newrev $(pwd)
}
 
# --- Config
# Set GIT_DIR either from the working directory, or from the environment
# variable.
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [ -z "$GIT_DIR" ]; then
echo >&2 "fatal: post-receive: GIT_DIR not set"
        exit 1
fi
 
# --- Main loop
# Allow dual mode: run from the command line just like the update hook, or
# if no arguments are given then run as a hook script
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
        # Output to the terminal in command line mode - if someone wanted to
        # resend an email; they could redirect the output to sendmail
        # themselves
        PAGER= generate_yammer $2 $3 $1
else
while read oldrev newrev refname
        do
generate_yammer $oldrev $newrev $refname
        done
fi