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 :)
This commit is contained in:
bluthej 2023-10-09 09:28:13 +02:00 committed by GitHub
parent 2d6557a51b
commit 38f512d588
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -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 -----

View file

@ -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 {