[license-reconcile] 02/02: Allow file aguments to restrict activity to stated files

Nicholas Bamber periapt at moszumanska.debian.org
Tue Nov 10 23:13:44 UTC 2015


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

periapt pushed a commit to branch master
in repository license-reconcile.

commit a5ec9584f60cd071d649d7a5fd3ea902bb2cb90d
Author: Nicholas Bamber <nicholas at periapt.co.uk>
Date:   Tue Nov 10 17:09:25 2015 +0000

    Allow file aguments to restrict activity to stated files
---
 bin/license-reconcile              | 25 +++++++++++++++++++++----
 debian/changelog                   |  1 +
 lib/Debian/LicenseReconcile/App.pm | 14 ++++++++++++++
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/bin/license-reconcile b/bin/license-reconcile
index d57c111..054a294 100755
--- a/bin/license-reconcile
+++ b/bin/license-reconcile
@@ -28,7 +28,7 @@ my $format_spec = 1;
 my @filters = qw(Rules ChangeLog Std Shebang Default~Rules);
 my @filters_override = ();
 
-# Defaut location of various files
+# Default location of various files
 my $config_file = 'debian/license-reconcile.yml';
 my $changelog_file = 'debian/changelog';
 my $directory = ".";
@@ -60,6 +60,8 @@ if (@filters_override) {
     @filters = @filters_override;
 }
 
+my $files = _package_args(@ARGV);
+
 my $app = Debian::LicenseReconcile::App->new(
     copyright           => $copyright_file,
     check_copyright     => $check_copyright,
@@ -71,9 +73,19 @@ my $app = Debian::LicenseReconcile::App->new(
     display_mapping     => $display_mapping,
     filters             => \@filters,
     format_spec         => $format_spec,
+    files		=> $files,
 );
 exit($app->run);
 
+sub _package_args {
+    my @files = @_;
+    my $result = undef;
+    if (@files) {
+	%$result = map {$_ => 1} @files;
+    }
+    return $result;
+}
+
 =head1 NAME
 
 license-reconcile - reconcile debian/copyright against source
@@ -82,7 +94,7 @@ license-reconcile - reconcile debian/copyright against source
 
 B<license-reconcile> B<--help>|B<--man>
 
-B<license-reconcile> [B<--copyright-file=>I<file>] [B<--no-check-copyright>] [B<--no-format-spec>] [B<--quiet>] [B<--display-mapping>] [B<--directory=>I<directory>] [B<--filters=>I<module1 module2 ...>] [B<--config-file=>I<file>] [B<--changelog-file=>I<file>]
+B<license-reconcile> [B<--copyright-file=>I<file>] [B<--no-check-copyright>] [B<--no-format-spec>] [B<--quiet>] [B<--display-mapping>] [B<--directory=>I<directory>] [B<--filters=>I<module1 module2 ...>] [B<--config-file=>I<file>] [B<--changelog-file=>I<file>] [I<files...>]
 
 =head1 DESCRIPTION
 
@@ -238,12 +250,12 @@ returned by a filter, subsequent filters will ignore it.
 
 =item - L<Rules|Debian::LicenseReconcile::Filter::Rules>
 
+=item - L<ChangeLog|Debian::LicenseReconcile::Filter::ChangeLog>
+
 =item - L<Std|Debian::LicenseReconcile::Filter::Std>
 
 =item - L<Shebang|Debian::LicenseReconcile::Filter::Shebang>
 
-=item - L<ChangeLog|Debian::LicenseReconcile::Filter::ChangeLog>
-
 =item - L<Default|Debian::LicenseReconcile::Filter::Default>
 
 =back
@@ -265,6 +277,11 @@ relevant to this filter.
 
 =back
 
+=head1 FILE ARGUMENTS
+
+Any arguments after the arguments are assumed to be files. If specified only
+these files will be reconciled.
+
 =head1 LIMITATIONS
 
 The DEP-5 specification is subtly different from the file glob specification.
diff --git a/debian/changelog b/debian/changelog
index 8d4c505..7445ccc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 license-reconcile (0.9) UNRELEASED; urgency=medium
 
   * Code reviewed: bin/license-reconcile [in progress]
+  * Allow file aguments to restrict activity to stated files
 
  -- Nicholas Bamber <nicholas at periapt.co.uk>  Sat, 07 Nov 2015 23:55:16 +0000
 
diff --git a/lib/Debian/LicenseReconcile/App.pm b/lib/Debian/LicenseReconcile/App.pm
index 08f8f08..5c3ff20 100644
--- a/lib/Debian/LicenseReconcile/App.pm
+++ b/lib/Debian/LicenseReconcile/App.pm
@@ -15,6 +15,7 @@ use Class::XSAccessor
         directory =>'directory',
         filters => 'filters',
         format_spec => 'format_spec',
+	files=>'files',
     },
 ;
 use File::Slurp;
@@ -94,6 +95,14 @@ sub _build_file_mapping {
     my $copyright_target = shift;
     my $file_mapping = $copyright_target->map_directory($self->directory);
 
+    if ($self->files) {
+	foreach my $key (keys %$file_mapping) {
+	    if (not exists $self->files->{$key}) {
+		delete $file_mapping->{$key};
+            }
+	}
+    }
+
     if ($self->display_mapping) {
         foreach my $file (sort keys %$file_mapping) {
             print "$file: $file_mapping->{$file}->{pattern}\n";
@@ -162,6 +171,7 @@ sub _run_filter {
     );
     foreach my $titbit ($test->get_info) {
         next if $file_checked->{$titbit->{file}};
+	next if $self->files and not exists $self->files->{$titbit->{file}};
         $file_checked->{$titbit->{file}} = 1;
         if (exists $file_mapping->{$titbit->{file}}) {
             $reconcile->check(
@@ -232,6 +242,8 @@ object.
 
 =head2 run
 
+This contains the core logic of the tool.
+
 =head2 quiet
 
 =head2 display_mapping
@@ -250,6 +262,8 @@ object.
 
 =head2 format_spec
 
+=head2 files
+
 =head1 AUTHOR
 
 Nicholas Bamber, C<< <nicholas at periapt.co.uk> >>

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



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