mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Do not insert newlines when diff is empty
This commit is contained in:
parent
67594e8ec2
commit
28169492f9
1 changed files with 12 additions and 4 deletions
|
@ -127,14 +127,22 @@ class CallbackBase:
|
|||
after_header = "after: %s" % diff['after_header']
|
||||
else:
|
||||
after_header = 'after'
|
||||
differ = difflib.unified_diff(to_unicode(diff['before']).splitlines(True), to_unicode(diff['after']).splitlines(True), before_header, after_header, '', '', 10)
|
||||
ret.extend(list(differ))
|
||||
ret.append('\n')
|
||||
differ = difflib.unified_diff(to_unicode(diff['before']).splitlines(True),
|
||||
to_unicode(diff['after']).splitlines(True),
|
||||
fromfile=before_header,
|
||||
tofile=after_header,
|
||||
fromfiledate='',
|
||||
tofiledate='',
|
||||
n=10)
|
||||
difflines = list(differ)
|
||||
if difflines:
|
||||
ret.extend(difflines)
|
||||
ret.append('\n')
|
||||
if 'prepared' in diff:
|
||||
ret.append(to_unicode(diff['prepared']))
|
||||
except UnicodeDecodeError:
|
||||
ret.append(">> the files are different, but the diff library cannot compare unicode strings\n\n")
|
||||
return u"".join(ret)
|
||||
return u''.join(ret)
|
||||
|
||||
def _get_item(self, result):
|
||||
if result.get('_ansible_no_log', False):
|
||||
|
|
Loading…
Reference in a new issue