Created
June 29, 2009 22:45
-
-
Save moritz/137857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use 5.010; | |
use MIME::Lite; | |
my $prev = '8b643d6119fd9e4a460e6ec12711fa347207a0ec'; | |
if (-e 'previous_mail_hash') { | |
$prev = `cat previous_mail_hash`; | |
chomp $prev; | |
} | |
open my $h, '-|', 'git', qw(log --reverse --pretty=format:%H:%an:%s), | |
"$prev..HEAD" | |
or die "Error while launching git log: $!"; | |
while (<$h>) { | |
chomp; | |
my ($hash, $author, $msg) = split /:/; | |
if ($msg =~ m/tests?\s+(?:for\s+)?\[?(?:bug|rt|perl)\s*#?(\d+)\]?/i) { | |
my $bugno = $1; | |
$prev = $hash; | |
system("echo $prev > previous_mail_hash"); | |
my @files = filelist_for_hash($hash); | |
next unless @files; | |
my $mail_body = @files == 1 | |
? "$files[0]" | |
: "at least one of these files: " . join(', ', @files); | |
say $msg; | |
my $mail = MIME::Lite->new( | |
From => '[email protected]', | |
To => '[email protected]', | |
Subject => "[perl #$bugno] tests available", | |
Type => 'TEXT', | |
Data => "This is an automatically generated mail to " | |
. "inform you that tests are now available in " | |
. $mail_body, | |
); | |
$mail->send('smtp', 'mx.develooper.com'); | |
sleep 5; | |
} | |
} | |
sub filelist_for_hash { | |
my $hash = shift; | |
my @res = qx/git show $hash/; | |
chomp @res; | |
return | |
map { s{^b/}{t/}; $_ } | |
map { (split ' ', $_, 2)[1] } | |
grep { /^\+\+\+ b/ } @res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment