summaryrefslogtreecommitdiff
path: root/BitKeeper/triggers/post-commit
blob: c3a61ed2dde8cd5ab0872ee8dd9894a92dc075ad (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/sh

#shift
if [ -n "$BK_USER" ]
then
  COMMITTER=$BK_USER
else
  COMMITTER=$USER
fi
FROM=$COMMITTER@mysql.com
COMMITS=commits@lists.mysql.com
DOCS=docs-commit@mysql.com
LIMIT=10000
VERSION="5.1"
BKROOT=`bk root`

if [ -x /usr/sbin/sendmail ]; then
  SENDMAIL=/usr/sbin/sendmail
else
  SENDMAIL=sendmail
fi

if [ "$REAL_EMAIL" = "" ]
then
 echo "Warning: you must set REAL_EMAIL in your profile"
else
 FROM=$REAL_EMAIL 
fi

BK_STATUS=$BK_STATUS$BK_COMMIT

if [ "$BK_STATUS" = OK ]
then 

HAS_ACTUAL_CHANGES=`bk cset -r+ -d | grep -v "^#"`
if [ "$HAS_ACTUAL_CHANGES" = "" ]
then
  echo ChangeSet had no real changes, not sending emails
  exit
fi

IS_MERGE=`bk changes -r+ -k -m`
if [ "$IS_MERGE" = "" ]
then
  echo Merge changeset, not sending mails
  exit
fi

CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet`
#
# composing subject lines of commit mails.
# if a fix targets to a WL and there is a bug referred
# then X-Bug mail header will contain the first found bug's number
#
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | \
     sed -ne 's/[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/BUG#\1/
              s/.*BUG#\([0-9][0-9]*\)/\1/p'`
WL=`bk -R prs -r+ -h -d':C:' ChangeSet | \
     sed -ne 's/[Ww][Ll] *# *\([0-9][0-9]*\).*$/WL#\1/
              s/.*\(WL#[0-9][0-9]*\)/ \1/p'`
if [ "$BUG" = "" ]
then
#  TO=dev-public@mysql.com
  BS=""
  BH=""
else
#  TO=dev-bugs@mysql.com
  BS=" BUG#$BUG"
# need newline here
  BH="X-Bug: $BUG
"
fi

#++
# commits@ or dev-private@ mail
#--

LIST="commits"
TO="commits@lists.mysql.com"
if [ -f .tree-is-private ]
then
  LIST="dev-private"
  TO="dev-private@mysql.com"
fi

 echo "Notifying $LIST list at $TO"
 (
   cat <<EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $TO
Subject: bk commit into $VERSION tree ($CHANGESET)$BS
X-CSetKey: <$CSETKEY>
$BH
Below is the list of changes that have just been committed into a local
$VERSION repository of $COMMITTER.  When $COMMITTER does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

EOF
  bk changes -v -r+
  bk rset -r+ -ah | bk gnupatch -h -dup -T
 ) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt

$SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt

#++
# docs-commit@ mail
# Picks up anything under the Docs subdirectory (relevant for docs team).
#--
 bk changes -v -r+ | grep -q "  Docs/"
 if [ $? -eq 0 ]
 then
  echo "Notifying docs list at $DOCS"
  (
    cat <<EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $DOCS
Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)$BS

EOF
  bk changes -v -r+
  bk rset -r+ -ah | bk gnupatch -h -dup -T
 ) > $BKROOT/BitKeeper/tmp/docs.txt
 $SENDMAIL -t < $BKROOT/BitKeeper/tmp/docs.txt
 fi

else
  echo "commit failed because '$BK_STATUS', you may need to re-clone..." 
fi