[devscripts] 03/03: wrap-and-sort: Avoid modifying an empty file

James McCoy jamessan at debian.org
Tue Sep 29 01:11:31 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 ca08f4819f392725a76764c03ad9ab988ffc31bd
Author: James McCoy <jamessan at debian.org>
Date:   Mon Sep 28 21:10:23 2015 -0400

    wrap-and-sort: Avoid modifying an empty file
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog      | 2 ++
 scripts/wrap-and-sort | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 83074f7..d581c36 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,8 @@ devscripts (2.15.9) UNRELEASED; urgency=medium
       are interesting and this avoids a “Permission denied” warning with apt
       versions that restrict access to the lists/partial directory.  Thanks to
       James Cowgill for the patch.  (Closes: #798252)
+  * wrap-and-sort:
+    + Avoid modifying an empty file.  (Closes: #789579)
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/scripts/wrap-and-sort b/scripts/wrap-and-sort
index f3a7e55..98a4bb5 100755
--- a/scripts/wrap-and-sort
+++ b/scripts/wrap-and-sort
@@ -145,7 +145,10 @@ class Install(object):
 
 def remove_trailing_whitespaces(filename):
     assert os.path.isfile(filename), "%s does not exist." % (filename)
-    content = open(filename).read().rstrip() + "\n"
+    content = open(filename).read()
+    if len(content) == 0:
+        return
+    content = content.rstrip() + "\n"
     lines = content.split("\n")
     lines = [l.rstrip() for l in lines]
     new_content = "\n".join(lines)

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