Created
October 31, 2010 21:46
-
-
Save yanick/657197 to your computer and use it in GitHub Desktop.
Create an RT bug out of a CPAN Testers report
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use URI; | |
use URI::QueryParam; | |
use LWP::Simple qw/ get /; | |
use File::Temp qw/ tempfile /; | |
use Email::Sender::Simple qw(sendmail); | |
use Email::Simple; | |
use Email::Simple::Creator; | |
use HTML::TreeBuilder::XPath; | |
use autodie; | |
my $from = '[email protected]'; | |
my $url = URI->new( shift || die ); | |
# we just want the report | |
$url->query_param( raw => 1 ); | |
my $report = HTML::TreeBuilder::XPath->new; | |
$report->parse( get $url ); | |
# which distribution? | |
( my $dist = $report->findvalue('/html/head/title') ) =~ | |
s/^.*?(\S+)-v?[\d_.]*$/$1/m; | |
$dist or die; | |
my ( $fh, $filename ) = tempfile(); | |
# Link to html version of the report | |
# for the ticket description | |
$url->query_param( raw => 0 ); | |
print {$fh} join "\n", "CPAN Tester Failure\n", $url, | |
$report->findvalue('/html/body/pre'); | |
system $ENV{EDITOR}, $filename; | |
open $fh, '<', $filename; | |
chomp( my $subject = <$fh> ); | |
print "sending email... "; | |
sendmail( | |
Email::Simple->create( | |
header => [ | |
To => "bug-$dist\@rt.cpan.org", | |
From => $from, | |
Subject => $subject, | |
], | |
body => do { local $/ = <$fh> }, | |
) ); | |
print "done\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment