Skip to content

Commit b2c5630

Browse files
committed
Change email hook to send to firehose + commits
Since many people do not want to see anything but master and -fixes on the -commits mailing list, that has been configured that way. However, some of us want to see all of the commits, so I created a new mailing lists called mythtv-firehose, which will get all of the commits (except ones we've already seen by repo/SHA1)
1 parent 87e151e commit b2c5630

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

git_hooks/email_hook.pl

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use English;
1414
use Cwd 'abs_path';
1515

16+
my $filtered = 0;
1617
my $r = shift;
1718

1819
unless ($r->method_number == Apache2::Const::M_POST) {
@@ -47,7 +48,7 @@
4748
4849
my $regexp = qr($config{'ignoreregexp'});
4950
if ($branch !~ $regexp) {
50-
exit 0;
51+
$filtered = 1;
5152
}
5253
5354
my $dbh = DBI->connect("dbi:mysql:database=".$config{'db'}{'database'}.
@@ -63,14 +64,22 @@
6364
6465
6566
# These maybe should go into a config file later
66-
my %headers = (
67+
my %commitsheaders = (
6768
"From" => 'MythTV <noreply@mythtv.org>',
6869
"To" => 'mythtv-commits@mythtv.org',
6970
"Reply-to" => 'mythtv-dev@mythtv.org',
7071
"X-Repository" => $repository,
7172
"X-Branch" => $branch,
7273
);
7374
75+
my %firehoseheaders = (
76+
"From" => 'MythTV <noreply@mythtv.org>',
77+
"To" => 'mythtv-firehose@mythtv.org',
78+
"Reply-to" => 'mythtv-dev@mythtv.org',
79+
"X-Repository" => $repository,
80+
"X-Branch" => $branch,
81+
);
82+
7483
foreach my $commit ( @{$payload->{"commits"}} ) {
7584
my $longsha = $commit->{"id"};
7685
$select_h->execute($repository,$longsha);
@@ -119,17 +128,25 @@
119128
$email .= "Modified:\n\n " . join("\n ", @array) . "\n\n";
120129
}
121130
122-
# Send the email
131+
# Send the firehose email
132+
send_email($subject, $email, \%firehoseheaders);
133+
134+
# Send the commits email
135+
send_email($subject, $email, \%commitsheaders) if !$filtered;
136+
137+
$insert_h->execute($repository,$longsha);
138+
}
139+
140+
sub send_email {
141+
my ($subject, $email, $headers) = @_;
142+
123143
my $msg = Mail::Send->new;
124144
$msg->subject($subject);
125-
foreach my $h (keys %headers) {
126-
$msg->set($h, $headers{$h});
145+
foreach my $h (keys %{$headers}) {
146+
$msg->set($h, $headers->{$h});
127147
}
128148
129149
my $fh = $msg->open;
130150
print $fh $email;
131151
$fh->close;
132-
133-
$insert_h->execute($repository,$longsha);
134152
}
135-

0 commit comments

Comments
 (0)