Skip to content

Commit

Permalink
Fix diff (old and new were reversed) (#7855)
Browse files Browse the repository at this point in the history
## 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 :)
  • Loading branch information
bluthej authored and konstin committed Oct 11, 2023
1 parent 7d658ef commit 66f28d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions crates/ruff_cli/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----
Expand Down Expand Up @@ -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 -----
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/source_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 66f28d4

Please sign in to comment.