[Git][reproducible-builds/diffoscope][master] 3 commits: Correct "recurse" typo.

Chris Lamb gitlab at salsa.debian.org
Wed Feb 27 23:46:35 CET 2019


Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
d41f09ba by Chris Lamb at 2019-02-27T22:11:17Z
Correct "recurse" typo.

- - - - -
a671bfba by Chris Lamb at 2019-02-27T22:11:58Z
Tidy definition of "no file-specific differences were detected" message suffix.

Gbp-Dch: ignore

- - - - -
e670a3cb by Chris Lamb at 2019-02-27T22:46:11Z
Improve the displayed comment when falling back to a binary diff to include the file type. (Closes: #49)

- - - - -


2 changed files:

- diffoscope/comparators/utils/file.py
- tests/comparators/test_binary.py


Changes:

=====================================
diffoscope/comparators/utils/file.py
=====================================
@@ -354,7 +354,7 @@ class File(object, metaclass=abc.ABCMeta):
                         ),
                     ]
                 )
-            # Don't recursve forever on archive quines, etc.
+            # Don't recurse forever on archive quines, etc.
             depth = self._as_container.depth
             no_recurse = depth >= Config().max_container_depth
             if no_recurse:
@@ -421,17 +421,19 @@ class File(object, metaclass=abc.ABCMeta):
                     difference = self.compare_bytes(other, source=source)
                     if difference is None:
                         return None
-                    suffix = (
-                        ' ({})'.format(self.magic_file_type)
-                        if self.magic_file_type != 'data'
-                        else ''
-                    )
-                    difference.add_comment(
-                        "Format-specific differences are supported for this "
-                        "file format, but no file-specific differences were "
-                        "detected. Falling back to a binary diff.{}".format(
-                            suffix
+                    try:
+                        infix = type(self).DESCRIPTION
+                    except AttributeError:
+                        infix = 'this file format'
+                    suffix = ''
+                    if self.magic_file_type != 'data':
+                        suffix = ' file(1) reports: {}'.format(
+                            self.magic_file_type
                         )
+                    difference.add_comment(
+                        "Format-specific differences are supported for {} but "
+                        "no file-specific differences were detected; falling "
+                        "back to a binary diff.{}".format(infix, suffix)
                     )
             except subprocess.CalledProcessError as e:
                 difference = self.compare_bytes(other, source=source)


=====================================
tests/comparators/test_binary.py
=====================================
@@ -127,13 +127,16 @@ def test_with_compare_details():
 @skip_unless_tools_exist('xxd')
 def test_with_compare_details_and_fallback():
     class MockFile(FilesystemFile):
+        DESCRIPTION = "mock files"
+
         def compare_details(self, other, source=None):
             return []
 
     difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH))
     expected_diff = get_data('binary_expected_diff')
     assert (
-        'but no file-specific differences were detected' in difference.comment
+        'supported for mock files but no file-specific differences were detected'
+        in difference.comment
     )
     assert normalize_zeros(difference.unified_diff) == expected_diff
 



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/40e5a5f115e7de8b455e11f30d1e6f9c83ec0c37...e670a3cb92a52868f843b8cc96c13da7b5616d24

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/compare/40e5a5f115e7de8b455e11f30d1e6f9c83ec0c37...e670a3cb92a52868f843b8cc96c13da7b5616d24
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190227/a8853825/attachment.html>


More information about the rb-commits mailing list