[libconfig-model-dpkg-perl] 03/04: write patch description body without synopsis (Closes: #842391)

dod at debian.org dod at debian.org
Fri Dec 2 18:07:53 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 5feb64747dcd6e6cd0138ef55c31ef4a76c1798a
Author: Dominique Dumont <dod at debian.org>
Date:   Fri Dec 2 18:53:45 2016 +0100

    write patch description body without synopsis (Closes: #842391)
    
    Fix for #842391 also requries the previous commits
---
 lib/Config/Model/Backend/Dpkg/Patch.pm | 63 ++++++++++++++++------------------
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/lib/Config/Model/Backend/Dpkg/Patch.pm b/lib/Config/Model/Backend/Dpkg/Patch.pm
index e7eb243..8df9038 100644
--- a/lib/Config/Model/Backend/Dpkg/Patch.pm
+++ b/lib/Config/Model/Backend/Dpkg/Patch.pm
@@ -162,8 +162,7 @@ sub write {
         message => "cannot write patch $patch_file" );
     $io->binmode(":utf8");
 
-    my $subject_body;
-    my $diff;
+    # first pass to write all headers
     foreach my $elt ( $node -> get_element_name ) {
         my $elt_obj = $node->fetch_element($elt) ;
         my $type = $node->element_type($elt) ;
@@ -175,42 +174,38 @@ sub write {
         foreach my $v (@v) {
             # say "write $elt -> $v" ;
             next unless defined $v and $v;
+            next if grep {$elt eq $_} qw/Description Subject Synopsis diff/;
 
-            if ($elt eq 'Synopsis') {
-                my $synopsis = $v ;
-                my $description_body = $node->fetch_element_value('Description') ;
-                $subject_body = $node->fetch_element_value('Subject') ;
-
-                if ($description_body and $subject_body) {
-                    die "Write error: cannot have both Subject body and description body";
-                }
-                elsif ($description_body) {
-                    my $to_write = $synopsis . "\n" . $description_body ;
-                    $io->print("Description: ");
-                    $self->write_dpkg_text($io, $to_write) ;
-                }
-                elsif ($subject_body) {
-                    # DEP-3: When Subject is used, it is expected that the
-                    # long description is outside of the structured
-                    # fields.
-                    $io->print("Subject: ");
-                    $self->write_dpkg_text($io, $synopsis) ;
-                }
-                else {
-                    $io->print("Description: ");
-                    $self->write_dpkg_text($io, $synopsis) ;
-                }
-            }
-            elsif ($elt eq 'Description' or $elt eq 'Subject' or $elt eq 'diff') {
-                # first 2 are handled with Synopsis. diff is handled below
-            }
-            else {
-                $io->print("$elt: ");
-                $self->write_dpkg_text($io,$v) ;
-            }
+            $io->print("$elt: ");
+            $self->write_dpkg_text($io,$v) ;
         }
     }
 
+    my $synopsis         = $node->fetch_element_value('Synopsis') || "";
+    my $description_body = $node->fetch_element_value('Description') ;
+    my $subject_body     = $node->fetch_element_value('Subject') ;
+
+    if ($description_body and $subject_body) {
+        die "Write error: cannot have both Subject body and description body";
+    }
+    elsif ($description_body) {
+        my $to_write = $synopsis . "\n" . $description_body ;
+        $io->print("Description: ");
+        $self->write_dpkg_text($io, $to_write) ;
+    }
+    elsif ($subject_body) {
+        # DEP-3: When Subject is used, it is expected that the
+        # long description is outside of the structured
+        # fields.
+        $io->print("Subject: ");
+        $self->write_dpkg_text($io, $synopsis) ;
+    }
+    else {
+        # no description body, write only synopsis
+        $io->print("Description: ");
+        $self->write_dpkg_text($io, $synopsis) ;
+    }
+
     if ($subject_body) {
         $io->print($subject_body."\n");
     }

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