[libconfig-model-dpkg-perl] 02/03: skip comment in copyright with -force option

dod at debian.org dod at debian.org
Tue Nov 22 20:02:09 UTC 2016


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 afa366636852437fcc34bb6bc3e9929ba55be105
Author: Dominique Dumont <dod at debian.org>
Date:   Tue Nov 22 20:59:30 2016 +0100

    skip comment in copyright with -force option
    
    .. which sets check arg to 'no'
---
 lib/Config/Model/Backend/DpkgSyntax.pm | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/Config/Model/Backend/DpkgSyntax.pm b/lib/Config/Model/Backend/DpkgSyntax.pm
index fed8830..0d50b4f 100644
--- a/lib/Config/Model/Backend/DpkgSyntax.pm
+++ b/lib/Config/Model/Backend/DpkgSyntax.pm
@@ -44,16 +44,24 @@ sub parse_dpkg_lines {
     my @res ; 
     
     foreach my $l (@$lines) {
-        $logger->trace("Parsing line $line_nb '$l'");
-        if ( $l =~ /^#/ ) { # comment are always located before the keyword (hopefully)
-            Config::Model::Exception::Syntax->throw (
-                object => $self,
-                parsed_line => $line_nb,
-                message => "Comments are not allowed",
-            ) unless $comment_allowed;
-            my $c = $l ;
-            $c =~ s/#\s// ;
-            push @comments, $c ;
+        $logger->trace("Parsing $file_path line $line_nb '$l'");
+        if ( $l =~ /^#/) { # comment are always located before the keyword (hopefully)
+            if ($comment_allowed) {
+                my $c = $l ;
+                $c =~ s/#\s// ;
+                push @comments, $c ;
+            }
+            else {
+                Config::Model::Exception::Syntax->throw (
+                    object => $self,
+                    parsed_file => $file_path,
+                    parsed_line => $line_nb,
+                    message => "Comments are not allowed. (use -force option to drop comments)",
+                ) if $check eq 'yes' ;
+                my $msg = "File $file_path: Dropped comment line $line_nb";
+                $logger->error($msg) if $check eq 'skip';
+                $logger->warn($msg) if $check eq 'no';
+            }
         }
         elsif ( $l =~ /^([\w\-]+)\s*:/ ) {  # keyword:
             my ($field,$text) = split /\s*:\s*/,$l,2 ;

-- 
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