summaryrefslogtreecommitdiffstats
path: root/gitmirror/robot.sh
blob: 8f7a25c86586b40dc070c34c3b2d7e23eb299101 (plain)
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
37
#!/bin/bash -xe

MAILTO='NASM commits list <nasm-cvs@lists.sourceforge.net>'
#MAILTO='NASM commits list <hpa+nasm/cvs@zytor.com>'
SENDER='nasmbuild@zytor.com'

# /usr/sbin needed for sendmail
export PATH=/bin:/usr/bin:/usr/local/bin:/usr/sbin:$HOME/bin

(
    flock -nx 8 || exit 0

    mkdir -m 0700 -p /tmp/$USER

    cd $HOME/gitmirror/git
    git fetch
    git reset --hard origin/master
    git push -f zytor
    git push --tags -f zytor
    
    HEAD=$(git-rev-parse HEAD)
    OLD_HEAD=$(cat ../LAST_EMAIL)
    
    if [ x"$HEAD" != x"$OLD_HEAD" ]; then
	mkdir -m 0700 /tmp/$USER/gitpatches.$$

	# -k = no [PATCH], since we're sending to a mailing list.
	git format-patch -M -C -C -k -o /tmp/gitpatches.$$ $OLD_HEAD..$HEAD

	for f in /tmp/gitpatches.$$/*; do
	    ../robotfmt.pl "$MAILTO" < "$f" | sendmail -f "$SENDER" -t
	done

	echo "$HEAD" > ../LAST_EMAIL
	rm -rf /tmp/$USER/gitpatches.$$
    fi
) 8< "$0"