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 5db2d8d474ac1d4209d41cb3adb71b78b66e403f
Author: Dominique Dumont <d...@debian.org>
Date:   Sun Jan 31 17:45:13 2016 +0100

    Scanner: can speicfy files to scan or ignore.
---
 lib/Config/Model/Dpkg/Copyright.pm | 28 +++++++++++---
 lib/Dpkg/Copyright/Scanner.pm      | 78 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 98 insertions(+), 8 deletions(-)

diff --git a/lib/Config/Model/Dpkg/Copyright.pm 
b/lib/Config/Model/Dpkg/Copyright.pm
index 2fc6bff..bb6ac43 100644
--- a/lib/Config/Model/Dpkg/Copyright.pm
+++ b/lib/Config/Model/Dpkg/Copyright.pm
@@ -328,13 +328,31 @@ Note: this command is experimental.
 
 =head1 Tweak results
 
-Results can be tweaked either by specyfying information for individual
-files or by tweaking the copyright entries created by grouping
-coaslescinf information.
+Results can be tweaked either by:
 
-The first way is described in L<Dpkg::Copyright::Scanner/"Filling the blanks">.
+=over
+
+=item *
+
+Changing the list of files to scan or ignore. (By default, licensecheck will 
decide
+which file to scan or not.)
+
+=item *
+
+Specifying information for individual files
+
+=item *
+
+Tweaking the copyright entries created by grouping and coaslescing
+information.
+
+=back
+
+The first 2 ways are described in
+L<Dpkg::Copyright::Scanner/"Selecting or ignoring files to scan">
+and L<Dpkg::Copyright::Scanner/"Filling the blanks">.
 
-The second way is described below:
+The last way is described below:
 
 =head2 Tweak copyright entries
 
diff --git a/lib/Dpkg/Copyright/Scanner.pm b/lib/Dpkg/Copyright/Scanner.pm
index 7e96a6f..8432ca7 100644
--- a/lib/Dpkg/Copyright/Scanner.pm
+++ b/lib/Dpkg/Copyright/Scanner.pm
@@ -90,12 +90,35 @@ sub _warn ($msg) {
     warn $msg unless $quiet;
 }
 
+# from licensecheck.pl
+my $default_ignore_regex = qr!
+# Ignore general backup files
+~$|
+# Ignore emacs recovery files
+(?:^|/)\.#|
+# Ignore vi swap files
+(?:^|/)\..*\.swp$|
+# Ignore baz-style junk files or directories
+(?:^|/),,.*(?:$|/.*$)|
+# File-names that should be ignored (never directories)
+(?:^|/)(?:DEADJOE|\.cvsignore|\.arch-inventory|\.bzrignore|\.gitignore)$|
+# File or directory names that should be ignored
+(?:^|/)(?:CVS|RCS|\.pc|\.deps|\{arch\}|\.arch-ids|\.svn|\.hg|_darcs|\.git|
+\.shelf|_MTN|\.bzr(?:\.backup|tags)?)(?:$|/.*$)
+!x;
+
+# cleanup the regexp
+$default_ignore_regex =~ s/#.*\n//g;
+$default_ignore_regex =~ s/\n//g;
+
 # option to skip UNKNOWN ?
 # load a file to override some entries ?
 sub scan_files ( %args ) {
 
     $quiet = $args{quiet} // 0;
 
+    my $current_dir = $args{from_dir} || path('.');
+
     my @lines ;
     if (my $file = $ENV{COPYRIGHT_SCANNER_INPUT}) {
         @lines = path($file)->lines_utf8 ; # for tests
@@ -104,16 +127,35 @@ sub scan_files ( %args ) {
         @lines = $args{in}->lines_utf8; # for other tests
     }
     else {
-        foreach my $opts ( ('--skipped', q! -c 
'(?i:readme|license|copying).*'!)) {
+        my @runs = (['--skipped'], [qw!-c (?i:readme|license|copying).*!]);
+
+        my $debian = $current_dir->child('debian');
+        my $scan_patterns = $debian->child("copyright-scan-patterns.yml");
+
+        if ($debian->is_dir and $scan_patterns->is_file) {
+            my $yaml = $scan_patterns->slurp_utf8;
+            # { check => { suffixes => [ js pl ], pattern => '[A-Z]*'}, ignore 
=> { suffixes => [ jpg png ], pattern => 'foo.*'} }
+            my $scan_data = Load $yaml;
+            my @opts = ();
+            foreach my $what (qw/check ignore/) {
+                my $data = $scan_data->{$what} or next;
+                my $reg = join( '|' , (map { '\.'.$_.'$'} @{$data->{suffixes} 
|| []}), @{ $data->{pattern} || []});
+                $reg .= '|' .$default_ignore_regex if $what eq 'ignore';
+                push @opts, '--skipped', "--$what=$reg";
+            }
+            @runs = \@opts ;
+        }
+
+        foreach my $opts ( @runs ) {
             my $pipe = IO::Pipe->new();
-            $pipe->reader("licensecheck --encoding utf8 --copyright -m -r 
$opts .");
+            my @cmd = (qw/licensecheck --encoding utf8 --copyright --machine 
--recursive/,  @$opts, '.');
+            $pipe->reader(@cmd);
             binmode($pipe, ":encoding(UTF-8)");
             push @lines, $pipe->getlines;
             $pipe->close;
         }
     }
 
-    my $current_dir = $args{from_dir} || path('.');
     my $fill_blank_data = __load_fill_blank_data($current_dir);
 
     my $is_debian_package = -d 'debian';
@@ -534,6 +576,36 @@ license information. Information are packed in a way to 
ease review and
 maintenance. Files information is grouped with wildcards ('*') to reduce
 the list of files.
 
+=head1 Selecting or ignoring files to scan
+
+By default, the decision whether to scan a file or not is left to 
L<licensecheck>.
+
+You can override this behavior in file
+C<debian/copyright-scan-patterns.yml>. This YAML file can
+contain a list of suffixes or patterns to scan or to ignore. Any file
+that is not scanned or ignored will be shown as "skipped".
+
+The file must have the following structure (all fields are optional
+and order does not matter):
+
+ ---
+ check :
+   suffixes :
+     - PL       # check .PL$
+     - pl
+   pattern:
+     - /README$
+ ignore :
+   suffixes :
+     - yml
+   pattern :
+     - /t/
+     - /models/
+     - /debian/
+     - /Changes
+
+Do not specify the dot with the suffixes. This will be added by the scanner.
+
 =head1 Filling the blanks
 
 Sometimes, upstream coders are not perfect: some source files cannot

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.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

Reply via email to