mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix file.line diff formatting.
Using _splitlines_preserving_trailing_newline() strips off line endings, mangling the unified_diff output. Switching to splitlines with the keepends option resolves this issue, while still preserving trailing newline. Fixes #41474
This commit is contained in:
parent
ea07f9c54c
commit
24d7315f1a
1 changed files with 2 additions and 4 deletions
|
@ -1856,10 +1856,8 @@ def line(path, content, match=None, mode=None, location=None,
|
|||
if changed:
|
||||
if show_changes:
|
||||
with salt.utils.fopen(path, 'r') as fp_:
|
||||
path_content = _splitlines_preserving_trailing_newline(
|
||||
fp_.read())
|
||||
changes_diff = ''.join(difflib.unified_diff(
|
||||
path_content, _splitlines_preserving_trailing_newline(body)))
|
||||
path_content = fp_.read().splitlines(True)
|
||||
changes_diff = ''.join(difflib.unified_diff(path_content, body.splitlines(True)))
|
||||
if __opts__['test'] is False:
|
||||
fh_ = None
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue