[Reproducible-commits] [diffoscope] 03/17: Be consistent in how we add comments

Jérémy Bobbio lunar at moszumanska.debian.org
Tue Dec 8 18:15:20 UTC 2015


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

lunar pushed a commit to branch pu/parallel2
in repository diffoscope.

commit f36e77ae4496a5e258ccff4de5ae66fd6385ffd4
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Tue Dec 8 17:57:48 2015 +0100

    Be consistent in how we add comments
    
    Let's always perform filtering and line splitting in `add_comment` instead
    of only in the constructor.
---
 diffoscope/difference.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index fc44093..9562b03 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -269,11 +269,7 @@ class Difference(object):
             else:
                 self._notifications.append(notification)
         self._comments = []
-        if comment:
-            if type(comment) is list:
-                self._comments.extend(comment)
-            else:
-                self._comments.append(comment)
+        self.add_comment(comment)
         self._unified_diff = None
         # allow to override declared file paths, useful when comparing
         # tempfiles
@@ -301,8 +297,7 @@ class Difference(object):
             difference.unified_diff = unified_diff
         except RequiredToolNotFound:
             difference.add_comment('diff is not available!')
-        if comment:
-            difference.add_comment(comment)
+        difference.add_comment(comment)
         return difference
 
     @staticmethod
@@ -383,8 +378,12 @@ class Difference(object):
         return self._comments
 
     def add_comment(self, comment):
-        for line in comment.splitlines():
-            self._comments.append(line)
+        if comment:
+            if type(comment) is list:
+                self._comments.extend(comment)
+            else:
+                for line in comment.splitlines():
+                    self._comments.append(line)
 
     @property
     def source1(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list