mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Improve --diff output when files lack trailing newlines
The behavior now matches GNU diff. Fixes #14094. Example of output before this change: TASK [healthchecks.io : hourly healthchecks.io ping] *************************** changed: [ranka] --- before: /etc/cron.hourly/mg-healthchecks-dot-io +++ after: /tmp/tmpOTvXTw @@ -1,2 +1,2 @@ #!/bin/sh -curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null+curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null after this change: TASK [healthchecks.io : hourly healthchecks.io ping] *************************** changed: [ranka] --- before: /etc/cron.hourly/mg-healthchecks-dot-io +++ after: /tmp/tmpOTvXTw @@ -1,2 +1,2 @@ #!/bin/sh -curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null \ No newline at end of file +curl -sS https://hchk.io/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null The added unit tests contain more examples. This commit also takes care to avoid "no newline at EOF" warnings when no_log is in effect, and also when modules return dicts rather than strings. (It also removes trailing whitespace from using json serialization when diffing dicts, because I hate trailing whitespace in Python source files, even if they're test files.)
This commit is contained in:
parent
a6fff93967
commit
0a7f2c202b
3 changed files with 176 additions and 8 deletions
|
@ -864,7 +864,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
if 'before' in diff:
|
||||
diff["before"] = ""
|
||||
if 'after' in diff:
|
||||
diff["after"] = " [[ Diff output has been hidden because 'no_log: true' was specified for this result ]]"
|
||||
diff["after"] = " [[ Diff output has been hidden because 'no_log: true' was specified for this result ]]\n"
|
||||
|
||||
return diff
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue