From 38f512d588db1c9d1c7352705bb57d4f066ede64 Mon Sep 17 00:00:00 2001 From: bluthej Date: Mon, 9 Oct 2023 09:28:13 +0200 Subject: [PATCH] Fix diff (old and new were reversed) (#7855) ## Summary Fixes #7853. The old and new source files were reversed in the call to `TextDiff::from_lines`, so the diff output of the CLI was also reversed. ## Test Plan Two snapshots were updated in the process, so any reversal should be caught :) --- crates/ruff_cli/tests/integration_test.rs | 12 ++++++------ crates/ruff_linter/src/source_kind.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ruff_cli/tests/integration_test.rs b/crates/ruff_cli/tests/integration_test.rs index 07275021c8f22..7937af211cab3 100644 --- a/crates/ruff_cli/tests/integration_test.rs +++ b/crates/ruff_cli/tests/integration_test.rs @@ -1111,8 +1111,8 @@ fn diff_shows_safe_fixes_by_default() { ----- stdout ----- @@ -1,2 +1,2 @@ x = {'a': 1, 'a': 1} - -print('foo') - +print(('foo')) + -print(('foo')) + +print('foo') ----- stderr ----- @@ -1142,10 +1142,10 @@ fn diff_shows_unsafe_fixes_with_opt_in() { exit_code: 1 ----- stdout ----- @@ -1,2 +1,2 @@ - -x = {'a': 1} - -print('foo') - +x = {'a': 1, 'a': 1} - +print(('foo')) + -x = {'a': 1, 'a': 1} + -print(('foo')) + +x = {'a': 1} + +print('foo') ----- stderr ----- diff --git a/crates/ruff_linter/src/source_kind.rs b/crates/ruff_linter/src/source_kind.rs index c98b5fc50ae33..1cca0017bbdaf 100644 --- a/crates/ruff_linter/src/source_kind.rs +++ b/crates/ruff_linter/src/source_kind.rs @@ -91,7 +91,7 @@ impl SourceKind { pub fn diff(&self, other: &Self, path: Option<&Path>, writer: &mut dyn Write) -> Result<()> { match (self, other) { (SourceKind::Python(src), SourceKind::Python(dst)) => { - let text_diff = TextDiff::from_lines(dst, src); + let text_diff = TextDiff::from_lines(src, dst); let mut unified_diff = text_diff.unified_diff(); if let Some(path) = path {