Correct CIA trigger to operate properly on all bk versions again.
[vuplus_openembedded] / BitKeeper / triggers / post-outgoing.ciabot
1 #!/bin/sh
2
3 # Copyright (C) 2004 Chris Larson <kergoth@handhelds.org>
4 #
5 # Sanity checks taken from the scripts on commits.bkbits.net
6 #       Copyright (C) 2003 Leonard Norrgard <leonard.norrgard@refactor.fi>
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330,
21 # Boston, MA 02111-1307, USA.
22
23 check_sanity () {
24     if [ X$BK_STATUS = XDRYRUN -o X$BK_STATUS = XNOTHING ]; then
25         return 1
26     fi
27
28     # In order to make sure only pushes to public BitKeeper repositories
29     # are broadcasted to #commits, we check that a) the parent repository
30     # is on bkbits.net and b) we are the client.
31     
32     # Is parent a public BitKeeper repository at bkbits.net?
33     if !(echo $BKD_HOST|grep -q bitkeeper.com); then
34         return 1
35     fi
36     
37     if [ $BK_SIDE != client ]; then
38         return 1
39     fi
40 }
41
42 # Check sanity - do we need to send anything?
43 check_sanity || exit 0
44
45 if (grep -q 'ChangeSet' $BK_CSETLIST); then
46     # new, correct csets-out format
47     nums=`bk changes -d:REV: - < $BK_CSETLIST`
48 else
49
50     # Convert numbers from the cset list into something useful
51     nums=
52     for s in `cat $BK_CSETLIST`; do
53         # translate cset serial to cset #
54         n=`bk prs -h -d"\\$if(:DS: -eq $s){:REV:}" ChangeSet`
55         # dont send notifications about empty ChangeSets
56         if test -z `bk prs -h -r"$n" -d'$if(:LI: -eq 0){$if(:LD: -eq 0){:REV:}}' ChangeSet`; then
57                 nums="$n $nums"
58         fi
59     done
60 fi
61
62 # Send notifications to CIA
63 if test -n "$nums"; then
64     echo "Sending notification to CIA irc bot (cia.navi.cx)."
65     (
66         for n in $nums; do
67             $BK_ROOT/BitKeeper/triggers/ciabot_bk.sh $n
68         done
69     ) &
70 fi
71 exit 0