-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds a new flag `--dry-run` that when given, prevents otherwise destructive file overwrite operations and instead prints a rich diff. The diff contains names of files which would be modified, and a git-like diff of what modifications *would* be made. The diff is human-readable, and not designed to be easily machine-readable. The change leverages the `similar` crate, on which we transitively depended on already anyway. Closes #152.
- Loading branch information
Showing
8 changed files
with
137 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/snapshots/cli__tests__files-inplace-python-dry-run-macos.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: "CommandSnap\n{\n args, stdin: None, stdout:\n stdout.split_inclusive('\\n').map(ToOwned::to_owned).collect_vec(),\n exit_code,\n}" | ||
info: | ||
stderr: [] | ||
--- | ||
args: | ||
- "--sorted" | ||
- "--glob" | ||
- "**/*.py" | ||
- foo | ||
- baz | ||
stdin: ~ | ||
stdout: | ||
- "1.py:\n" | ||
- "- # This string is found and touched: foo\n" | ||
- "+ # This string is found and touched: baz\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
- "subdir/2.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
- "subdir/subdir/3.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
exit_code: 0 |
23 changes: 23 additions & 0 deletions
23
tests/snapshots/cli__tests__language-scoping-and-files-inplace-python-dry-run-macos.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: "CommandSnap\n{\n args, stdin: None, stdout:\n stdout.split_inclusive('\\n').map(ToOwned::to_owned).collect_vec(),\n exit_code,\n}" | ||
info: | ||
stderr: [] | ||
--- | ||
args: | ||
- "--sorted" | ||
- "--python" | ||
- function-names | ||
- "--glob" | ||
- subdir/**/*.py | ||
- foo | ||
- baz | ||
stdin: ~ | ||
stdout: | ||
- "subdir/2.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
- "subdir/subdir/3.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
exit_code: 0 |
27 changes: 27 additions & 0 deletions
27
tests/snapshots/cli__tests__language-scoping-inplace-python-dry-run-macos.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
source: tests/cli.rs | ||
expression: "CommandSnap\n{\n args, stdin: None, stdout:\n stdout.split_inclusive('\\n').map(ToOwned::to_owned).collect_vec(),\n exit_code,\n}" | ||
info: | ||
stderr: [] | ||
--- | ||
args: | ||
- "--sorted" | ||
- "--python" | ||
- function-names | ||
- foo | ||
- baz | ||
stdin: ~ | ||
stdout: | ||
- "1-shebanged:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
- "1.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
- "subdir/2.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
- "subdir/subdir/3.py:\n" | ||
- "- def foo(bar: int) -> int:\n" | ||
- "+ def baz(bar: int) -> int:\n" | ||
exit_code: 0 |