java-diff-utils
java-diff-utils copied to clipboard
Adding a new line at the end of a file is ignored
Describe the bug When adding a new line to a file it is ignored
To Reproduce Steps to reproduce the behavior:
- Using the following test (kotlin)
val beforeContent = "rootProject.name = \"sample-repo\""
val afterContent = "rootProject.name = \"sample-repo\"\n"
val patch = "diff --git a/settings.gradle b/settings.gradle\n" +
"index ef3b8e2..ab30124 100644\n" +
"--- a/settings.gradle\n" +
"+++ b/settings.gradle\n" +
"@@ -1 +1 @@\n" +
"-rootProject.name = \"sample-repo\"\n" +
"\\ No newline at end of file\n" +
"+rootProject.name = \"sample-repo\"\n"
val unifiedDiff = UnifiedDiffReader.parseUnifiedDiff(patch.byteInputStream())
val unifiedAfterContent = unifiedDiff.files[0].patch.applyTo(beforeContent.split("\n")).joinToString("\n")
assertEquals(afterContent, unifiedAfterContent)
Expected behavior The test should have equal content after applying the patch
You are right. I investigated so much time implementing this \ No newline at ... and forgot to use it for the patch itself. :)
Stale issue message