-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #132 - --diff option introduced and tested
- Loading branch information
1 parent
5983819
commit 3fd84ad
Showing
7 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
############################################################################### | ||
# Copyright Maciej Patro (maciej.patro@gmail.com) | ||
# MIT License | ||
############################################################################### | ||
|
||
|
||
import difflib | ||
from pathlib import Path | ||
|
||
|
||
def get_unified_diff(original: str, modified: str, filename: Path) -> str: | ||
diff = difflib.unified_diff(a=original.splitlines(keepends=True), | ||
b=modified.splitlines(keepends=True), | ||
fromfile=str(filename), | ||
tofile=str(filename)) | ||
return ''.join(diff) |
8 changes: 5 additions & 3 deletions
8
...ntegration/approved_files/TestCMakeTidyFormat.test_format_command_help_shown.approved.txt
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
usage: cmake-tidy format [-h] [--dump-config] [-i] [input] | ||
usage: cmake-tidy format [-h] [--dump-config] [-i] [--diff] [input] | ||
|
||
positional arguments: | ||
input CMake file to be formatted | ||
|
||
optional arguments: | ||
-h, --help show this help message and exit | ||
--dump-config dump to stdout current settings. Script tries to read | ||
--dump-config Dump to stdout current settings. Script tries to read | ||
settings from `.cmake-tidy.json` or provides default | ||
settings. Precedence of searching `.cmake-tidy.json` is | ||
described on github | ||
-i, --inplace inplace edit specified <input_data> file | ||
-i, --inplace Inplace edit specified <input_data> file | ||
--diff Print to stdout unified diff between original file and | ||
formatted version. |
26 changes: 26 additions & 0 deletions
26
..._files/TestCMakeTidyFormat.test_format_should_provide_unified_diff_to_stdout.approved.txt
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 @@ | ||
--- <replaced_path>/arguments.cmake | ||
+++ <replaced_path>/arguments.cmake | ||
@@ -7,15 +7,17 @@ | ||
|
||
# Here we have a line comment with weird stuff like #[===]] $#%!#@$!#@%^^%$&% | ||
set([==[ currently a weird bracket argument introduced | ||
-some 2839697%%*^$& text ]===] fake close and stuff]==] some | ||
- other | ||
- [===[www]===] | ||
- [======[this | ||
+some 2839697%%*^$& text ]===] fake close and stuff]==] | ||
+ some | ||
+ other | ||
+ [===[www]===] | ||
+[======[this | ||
should | ||
be | ||
indented differently | ||
]======] | ||
- "quoted argument with \" escaped quote") | ||
+ "quoted argument with \" escaped quote" | ||
+) | ||
|
||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
|
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