[devscripts] 02/04: wrap-and-sort: Always filter out empty list items

James McCoy jamessan at debian.org
Wed Apr 29 03:03:16 UTC 2015


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

jamessan pushed a commit to branch master
in repository devscripts.

commit 5d9b06a9792b804d0bc7dd39f4faee84d762c015
Author: James McCoy <jamessan at debian.org>
Date:   Tue Apr 28 21:13:30 2015 -0400

    wrap-and-sort: Always filter out empty list items
    
    When “-t” is used, the trailing commas cause an empty element to be part
    of the list of items being wrapped/sorted.  If they aren't removed, then
    running “-t” multiple times will add a new, empty item every time.
    
    Also, as previously noted, empty items can cause problems with QA tools,
    so lifting the “empty element removal” out of the sort handling provides
    better protection against that.
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog      | 5 +++++
 scripts/wrap-and-sort | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 3aaef9c..6f8f66b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,14 @@
 devscripts (2.15.5) UNRELEASED; urgency=medium
 
+  [ Cyril Brulebois ]
   * Update chdist bash-completion file with the architectures currently (as
     of 2015-04-28) listed on buildd.debian.org and buildd.debian-ports.org.
     (Closes: #783634)
 
+  [ James McCoy ]
+  * wrap-and-sort: Always remove empty elements from lists so “-t” doesn't add
+    a new, empty element.  (Closes: #783630)
+
  -- Cyril Brulebois <kibi at debian.org>  Tue, 28 Apr 2015 16:58:36 +0200
 
 devscripts (2.15.4) unstable; urgency=medium
diff --git a/scripts/wrap-and-sort b/scripts/wrap-and-sort
index b66e3e2..46d21c3 100755
--- a/scripts/wrap-and-sort
+++ b/scripts/wrap-and-sort
@@ -92,7 +92,9 @@ class WrapAndSortControl(Control):
 
     def _wrap_field(self, control, entry, wrap_always, short_indent,
                     trailing_comma, sort=True):
-        packages = [x.strip() for x in control[entry].split(",")]
+        # An empty element is not explicitly disallowed by Policy but known to
+        # break QA tools, so remove any
+        packages = list(filter(None, [x.strip() for x in control[entry].split(",")]))
 
         # Sanitize alternative packages. E.g. "a|b  |c" -> "a | b | c"
         packages = [" | ".join([x.strip() for x in p.split("|")]) for p in packages]
@@ -100,9 +102,6 @@ class WrapAndSortControl(Control):
         if sort:
             # Remove duplicate entries
             packages = set(packages)
-            # Not explicitly disallowed by Policy but known to break QA tools:
-            if "" in packages:
-                packages.remove("")
             packages = sort_list(packages)
 
         length = len(entry) + sum([2 + len(package) for package in packages])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list