Commit 2236701a authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Correctly identify changes to only the line-endings of files; don't mark them...

Correctly identify changes to only the line-endings of files; don't mark them as "Ordering differences only".
parent 9fa3171f
Loading
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -403,7 +403,7 @@ class Difference:
        self._visuals.extend(visuals)
        self._size_cache = None

    def has_ordering_differences_only(self):
    def check_for_ordering_differences(self):
        """
        Check if difference is only in line ordering.
        """
@@ -420,15 +420,11 @@ class Difference:

        # Faster check: does number of lines match?
        if len(added_lines) != len(removed_lines):
            return False
            return

        if added_lines == removed_lines:
            return True

        return sorted(added_lines) == sorted(removed_lines)

    def check_for_ordering_differences(self):
        if self.has_ordering_differences_only():
            self.add_comment("Line-ending differences only")
        elif sorted(added_lines) == sorted(removed_lines):
            self.add_comment("Ordering differences only")


+8 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ def test_compare_non_existing(monkeypatch, ascii1):

text_order1 = load_fixture("text_order1")
text_order2 = load_fixture("text_order2")
text_endings1 = load_fixture("text_endings1")
text_endings2 = load_fixture("text_endings2")


def test_ordering_differences(text_order1, text_order2):
@@ -97,6 +99,12 @@ def test_ordering_differences(text_order1, text_order2):
    assert_diff(difference, "text_order_expected_diff")


def test_ending_differences(text_endings1, text_endings2):
    difference = text_endings1.compare(text_endings2)
    assert difference.comments == ["Line-ending differences only"]
    assert_diff(difference, "text_endings_expected_diff")


def test_text_fallback(tmp_path):
    """
    If we don't know the exact type but it looks like text, compare it as text.
+3 −0
Original line number Diff line number Diff line
artifactId=logback-core
groupId=ch.qos.logback
version=1.2.13
+3 −0
Original line number Diff line number Diff line
artifactId=logback-core
groupId=ch.qos.logback
version=1.2.13
+7 −0
Original line number Diff line number Diff line
@@ -1,3 +1,3 @@
-artifactId=logback-core
-groupId=ch.qos.logback
-version=1.2.13
+artifactId=logback-core
+groupId=ch.qos.logback
+version=1.2.13