1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-06 05:08:42 +02:00

diff: if file doesn't end with newline, append one together with diffutils-like

comment line. Bug reported by Dirk Stoecker.
This commit is contained in:
Dr. Peter Poeml
2007-06-14 09:39:00 +00:00
parent 48349f67b9
commit e8ca5f0028

View File

@@ -1007,6 +1007,14 @@ def get_source_file_diff(dir, filename, rev):
fromfile = '%s (revision %s)' % (filename, rev), \
tofile = '%s (working copy)' % filename)
# if file doesn't end with newline, we need to append one in the diff result
d = list(d)
for i, line in enumerate(d):
if not line.endswith('\n'):
d[i] += '\n\\ No newline at end of file'
if i+1 != len(d):
d[i] += '\n'
return ''.join(d)