[pkg-perl-tools] 02/04: Build a new Message object from global vars

Alex Muntada alexm-guest at moszumanska.debian.org
Fri Dec 2 23:27:25 UTC 2016


This is an automated email from the git hooks/post-receive script.

alexm-guest pushed a commit to branch master
in repository pkg-perl-tools.

commit ce03edfe509abe8bd0572fbef98f8c5bae9fb376
Author: Alex Muntada <alexm at alexm.org>
Date:   Fri Dec 2 18:38:49 2016 +0100

    Build a new Message object from global vars
---
 lib/Debian/PkgPerl/Message.pm | 37 +++++++++++++++++++++++++++++++------
 scripts/forward               | 34 ++++++++++++++++++++++------------
 2 files changed, 53 insertions(+), 18 deletions(-)

diff --git a/lib/Debian/PkgPerl/Message.pm b/lib/Debian/PkgPerl/Message.pm
index 2da91a0..2056b03 100644
--- a/lib/Debian/PkgPerl/Message.pm
+++ b/lib/Debian/PkgPerl/Message.pm
@@ -39,7 +39,13 @@ sub new {
 }
 
 sub get_subject {
-    my $default = ( $bug ? $bug_info{Subject} : $patch_info{Subject} ) // '';
+    my $self = shift;
+
+    my $info        = $self->{info};
+    my $patch       = $self->{patch};
+    my $opt_tracker = $self->{tracker};
+
+    my $default = $info->{Subject} // '';
     $default = "[PATCH] $default"
         if $patch and $default !~ /\[PATCH\]/ and $opt_tracker ne 'github';
 
@@ -49,8 +55,11 @@ sub get_subject {
 }
 
 sub edit_message {
+    my $self = shift;
     my $body = shift or confess;
 
+    my $opt_tracker_url = $self->{url};
+
     $body
         = "# Feel free to edit the message contents to your liking.\n"
         . "# Fiddling with the patch itself is probably a bad idea.\n"
@@ -71,21 +80,29 @@ sub edit_message {
 }
 
 sub prepare_body {
+    my $self = shift;
     my $body;
 
+    my $bug         = $self->{bug};
+    my $opt_dist    = $self->{dist};
+    my $info        = $self->{info};
+    my $patch       = $self->{patch};
+    my $opt_tracker = $self->{tracker};
+    my $name        = $self->{name};
+
     $Text::Wrap::columns = 70;
     $Text::Wrap::huge    = 'overflow';
 
     if ($bug) {
         $body = "We have the following bug reported to the Debian package "
-            . "of $opt_dist ($bug_info{url}):" . "\n";
+            . "of $opt_dist ($info->{url}):" . "\n";
         $body .= "\nIt doesn't seem to be a bug in the packaging, "
             . "so you may want to take a look. Thanks!\n";
         $body = wrap( '', '', $body );
 
         $body .= "\n" . $scissors_line;
         $body .= "\n\`\`\`" if $opt_tracker eq 'github';
-        $body .= "\n" . $bug_info{msg};
+        $body .= "\n" . $info->{msg};
         $body .= "\n\`\`\`" if $opt_tracker eq 'github';
         $body .= "\n" . $scissors_line . "\n";
 
@@ -141,13 +158,21 @@ sub prepare_body {
     $body .= "\nThanks for considering,\n";
     $body .= wrap( '  ', '  ', "$name,\nDebian Perl Group\n" );
 
-    return edit_message($body);
+    return $self->edit_message($body);
 }
 
 sub send_by_mail {
+    my $self = shift;
+
+    my $name            = $self->{name};
+    my $email           = $self->{email};
+    my $opt_mailto      = $self->{mailto};
+    my $patch           = $self->{patch};
+    my $opt_tracker_url = $self->{url};
+
     my $from    = "$name <$email>";
-    my $text    = prepare_body();
-    my $subject = get_subject();
+    my $text    = $self->prepare_body();
+    my $subject = $self->get_subject();
 
     my $msg = MIME::Lite->new(
         From    => $from,
diff --git a/scripts/forward b/scripts/forward
index 2f6c10e..b57d5eb 100755
--- a/scripts/forward
+++ b/scripts/forward
@@ -215,7 +215,28 @@ my $bug_info = Debian::PkgPerl::Bug->new(
 );
 %bug_info = $bug_info->retrieve_bug_info() if $bug;
 
-my $message = Debian::PkgPerl::Message->new();
+my $name = $ENV{'DEBFULLNAME'};
+my $email
+    = $ENV{'DEBEMAIL'}
+    || $ENV{'EMAIL'}
+    || die "Err: Set a valid email address";
+
+if ( !$name ) {
+    $name = ( getpwuid($<) )[6];
+    $name =~ s/,.*//;
+}
+
+my $message = Debian::PkgPerl::Message->new(
+    bug     => $bug,
+    patch   => $patch,
+    info    => $bug ? \%bug_info : \%patch_info,
+    tracker => $opt_tracker,
+    url     => $opt_tracker_url,
+    dist    => $opt_dist,
+    name    => $name,
+    email   => $email,
+    mailto  => $opt_mailto,
+);
 
 sub detect_dist {
     return $upstream_metadata->{Name}
@@ -256,17 +277,6 @@ sub detect_dist {
     return;
 }
 
-my $name = $ENV{'DEBFULLNAME'};
-my $email
-    = $ENV{'DEBEMAIL'}
-    || $ENV{'EMAIL'}
-    || die "Err: Set a valid email address";
-
-if ( !$name ) {
-    $name = ( getpwuid($<) )[6];
-    $name =~ s/,.*//;
-}
-
 # RT config
 my $rt_server = 'https://rt.cpan.org';
 my %rt_login;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git



More information about the Pkg-perl-cvs-commits mailing list