Skip to content

Instantly share code, notes, and snippets.

@yanick
Created October 31, 2010 21:46
Show Gist options
  • Save yanick/657197 to your computer and use it in GitHub Desktop.
Save yanick/657197 to your computer and use it in GitHub Desktop.
Create an RT bug out of a CPAN Testers report
#!/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 = 'yanick@babyl.dyndns.org';
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