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 ca6442e3c7aad9ea53822e5c50853b728de38289 Author: Alex Muntada <al...@alexm.org> Date: Fri Dec 2 22:15:47 2016 +0100 Extract patch info sub into a Patch class --- lib/Debian/PkgPerl/Patch.pm | 96 +++++++++++++++++++++++++++++++++++++++++++++ scripts/forward | 40 ++----------------- 2 files changed, 99 insertions(+), 37 deletions(-) diff --git a/lib/Debian/PkgPerl/Patch.pm b/lib/Debian/PkgPerl/Patch.pm new file mode 100644 index 0000000..64551f1 --- /dev/null +++ b/lib/Debian/PkgPerl/Patch.pm @@ -0,0 +1,96 @@ +package Debian::PkgPerl::Patch; + +use strict; +use warnings; + +use autodie; +use Carp; +use File::Spec; + +=head1 NAME + +Debian::PkgPerl::Patch - Retrieves patch information to be forwarded. + +=head1 SYNOPSIS + + use Debian::PkgPerl::Patch; + my $msg = Debian::PkgPerl::Patch->new(); + my %info = $msg->retrieve_patch_info(); + +=head1 DESCRIPTION + +Helper class that retrieves information related to the patch being +forwarded upstream. + +=cut + +sub new { + my $class = shift; + my %params = @_; + + return bless \%params, $class; +} + +sub retrieve_patch_info { + open( my $in, "<", $patch ); + my $line_no = 1; + while ( $line_no <= 10 ) { + my $line = <$in>; + chomp($line); + + last if $line =~ /^(?:diff|index|---|\+\+\+)/s; + + if ( $line !~ /^Forwarded: not yet/i + and $line !~ /^Forwarded: no$/i + and $line =~ /^(?:Forwarded|Bug): (\S+)/i ) + { + if ($opt_force) { + warn "Patch already forwarded to $1\n"; + warn "Continuing anyway because of --force.\n"; + } + else { + die "Patch already forwarded to $1\n"; + } + } + + $patch_info{Subject} = $1 + if $line =~ /^(?:Subject|Description):\s+(.+)/; + $patch_info{From} = $1 + if $line =~ /^(?:From|Author):\s+(.+)/; + $line_no++; + } + + unless ( $patch_info{Subject} ) { + # TODO: Use basename($patch) instead? + # default subject is the patch name + my $fn = ( File::Spec->splitpath($patch) )[-1]; + $fn =~ s/\.(?:patch|diff)$//; # strip extension + $fn =~ s/^\d+[-_]?//; # strip leading number + $fn =~ s/(\_|\-)/ /g; # spaces make reading easier + $patch_info{Subject} = $fn; + } +} + +=head1 LICENSE AND COPYRIGHT + +=over + +=item Copyright 2016 Alex Muntada. + +=item Copyright 2014 Salvatore Bonaccorso. + +=item Copyright 2014 Damyan Ivanov. + +=item Copyright 2011 Alessandro Ghedini. + +=back + +This program is free software; you can redistribute it and/or modify it +under the terms of either: the GNU General Public License as published +by the Free Software Foundation; or the Artistic License. + +See http://dev.perl.org/licenses/ for more information. + +=cut + +1; diff --git a/scripts/forward b/scripts/forward index a0fbdb4..417422b 100755 --- a/scripts/forward +++ b/scripts/forward @@ -17,6 +17,7 @@ use Proc::InvokeEditor; use MIME::Lite; use YAML::XS qw(LoadFile); use Debian::PkgPerl::Bug; +use Debian::PkgPerl::Patch; use Debian::PkgPerl::GitHub; use warnings; @@ -206,43 +207,8 @@ else { } if ($patch) { - open( my $in, "<", $patch ); - my $line_no = 1; - while ( $line_no <= 10 ) { - my $line = <$in>; - chomp($line); - - last if $line =~ /^(?:diff|index|---|\+\+\+)/s; - - if ( $line !~ /^Forwarded: not yet/i - and $line !~ /^Forwarded: no$/i - and $line =~ /^(?:Forwarded|Bug): (\S+)/i ) - { - if ($opt_force) { - warn "Patch already forwarded to $1\n"; - warn "Continuing anyway because of --force.\n"; - } - else { - die "Patch already forwarded to $1\n"; - } - } - - $patch_info{Subject} = $1 - if $line =~ /^(?:Subject|Description):\s+(.+)/; - $patch_info{From} = $1 - if $line =~ /^(?:From|Author):\s+(.+)/; - $line_no++; - } - - unless ( $patch_info{Subject} ) { - # TODO: Use basename($patch) instead? - # default subject is the patch name - my $fn = ( File::Spec->splitpath($patch) )[-1]; - $fn =~ s/\.(?:patch|diff)$//; # strip extension - $fn =~ s/^\d+[-_]?//; # strip leading number - $fn =~ s/(\_|\-)/ /g; # spaces make reading easier - $patch_info{Subject} = $fn; - } + my $patch_info = Debian::PkgPerl::Patch->new(); + %patch_info = $patch_info->retrieve_patch_info(); } my $bug_info = Debian::PkgPerl::Bug->new( -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits