[libconfig-model-dpkg-perl] 11/27: Copyright::Scanner: re-arrange and consolidate copyright years
dod at debian.org
dod at debian.org
Mon Jan 12 07:09:47 UTC 2015
This is an automated email from the git hooks/post-receive script.
dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.
commit 5ec4e1c9f4d6e0536bc72c744664a83b75f158f7
Author: Dominique Dumont <dod at debian.org>
Date: Sat Dec 27 17:06:36 2014 +0100
Copyright::Scanner: re-arrange and consolidate copyright years
---
lib/Dpkg/Copyright/Scanner.pm | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/lib/Dpkg/Copyright/Scanner.pm b/lib/Dpkg/Copyright/Scanner.pm
index a5ea836..162ab2f 100644
--- a/lib/Dpkg/Copyright/Scanner.pm
+++ b/lib/Dpkg/Copyright/Scanner.pm
@@ -8,6 +8,7 @@ use warnings;
use 5.20.0;
use IO::Pipe;
use Exporter::Lite;
+use Array::IntSpan;
use feature qw/postderef signatures/;
no warnings qw/experimental::postderef experimental::signatures/;
@@ -85,6 +86,8 @@ sub scan_files {
$c =~ s/\b(\d{4}),?\s+([\S^\d])/$1, $2/g;
$c =~ s/\.[\w\s]+$/./;
+ $c = __pack_copyright($c);
+
my $a = $copyrights{$c}{$l} //= $id++;
# split file path and fill recursive hash, leaf is id
my @path = split m!/!,$f;
@@ -124,6 +127,32 @@ sub scan_files {
return @copyright_data;
}
+sub __pack_copyright ($r) {
+
+ my %cop;
+ $r =~ /^\s+|\s+$/g;
+ foreach my $c ( split( m!\s*/\s*!, $r)) {
+ my @data = split /(?<=\d)[,\s]+/, $c;
+ my $owner = pop @data;
+ $owner =~ s/^\s+|\s+$//g;
+ $cop{$owner} = \@data ;
+ }
+
+ my @res ;
+ foreach my $owner (keys %cop) {
+ my $span = Array::IntSpan->new();
+ my $data = $cop{$owner};
+ foreach my $year ($data->@*) {
+ return $r if $year =~ /[^\d-]/; # bail-out
+ $span->set_range_as_string($year, $owner);
+ }
+ $span->consolidate();
+ push @res, $span->get_range_list. ', '. $owner;
+ }
+
+ return join("\n ", at res);
+}
+
#in each directory, pack files that have the same copyright/license information
sub __pack ($h, $pack, @path) {
my $old_id ;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.git
More information about the Pkg-perl-cvs-commits
mailing list