|
13 | 13 | use English; |
14 | 14 | use Cwd 'abs_path'; |
15 | 15 |
|
| 16 | +my $filtered = 0; |
16 | 17 | my $r = shift; |
17 | 18 |
|
18 | 19 | unless ($r->method_number == Apache2::Const::M_POST) { |
|
47 | 48 |
|
48 | 49 | my $regexp = qr($config{'ignoreregexp'}); |
49 | 50 | if ($branch !~ $regexp) { |
50 | | - exit 0; |
| 51 | + $filtered = 1; |
51 | 52 | } |
52 | 53 |
|
53 | 54 | my $dbh = DBI->connect("dbi:mysql:database=".$config{'db'}{'database'}. |
|
63 | 64 |
|
64 | 65 |
|
65 | 66 | # These maybe should go into a config file later |
66 | | -my %headers = ( |
| 67 | +my %commitsheaders = ( |
67 | 68 | "From" => 'MythTV <noreply@mythtv.org>', |
68 | 69 | "To" => 'mythtv-commits@mythtv.org', |
69 | 70 | "Reply-to" => 'mythtv-dev@mythtv.org', |
70 | 71 | "X-Repository" => $repository, |
71 | 72 | "X-Branch" => $branch, |
72 | 73 | ); |
73 | 74 |
|
| 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 | +
|
74 | 83 | foreach my $commit ( @{$payload->{"commits"}} ) { |
75 | 84 | my $longsha = $commit->{"id"}; |
76 | 85 | $select_h->execute($repository,$longsha); |
|
119 | 128 | $email .= "Modified:\n\n " . join("\n ", @array) . "\n\n"; |
120 | 129 | } |
121 | 130 |
|
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 | +
|
123 | 143 | my $msg = Mail::Send->new; |
124 | 144 | $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}); |
127 | 147 | } |
128 | 148 |
|
129 | 149 | my $fh = $msg->open; |
130 | 150 | print $fh $email; |
131 | 151 | $fh->close; |
132 | | -
|
133 | | - $insert_h->execute($repository,$longsha); |
134 | 152 | } |
135 | | -
|
|
0 commit comments