From f7c9a0f5b3326f5997dd3fcb4e2b1013696e0638 Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Fri, 4 Dec 2020 10:44:25 +0100 Subject: [PATCH 1/5] #1284 Set next development version --- cobigen/cobigen-textmerger/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen/cobigen-textmerger/pom.xml b/cobigen/cobigen-textmerger/pom.xml index 71f7bedac0..7b40cc9a8f 100644 --- a/cobigen/cobigen-textmerger/pom.xml +++ b/cobigen/cobigen-textmerger/pom.xml @@ -2,7 +2,7 @@ 4.0.0 textmerger jar - 7.1.0 + 7.2.0-SNAPSHOT CobiGen - Text Merger Plug-in CobiGen - Text Merger Plug-in From c7d5a264f444478544b1bcda7e88825a8788df9e Mon Sep 17 00:00:00 2001 From: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com> Date: Mon, 14 Dec 2020 22:24:49 +0100 Subject: [PATCH 2/5] fixed #1294 (#1298) added new testMerge_noBaseLineDelimiterToConsolidate test made sure to only call consolidateLineEndings if determineLineDelimiter detected line endings in base file --- .../devonfw/cobigen/textmerger/TextAppender.java | 14 +++++++------- .../cobigen/textmerger/TextAppenderTest.java | 15 +++++++++++++++ .../test/resources/MergedBaseNoLineDelimiter.txt | 2 ++ .../test/resources/PatchBaseNoLineDelimiter.txt | 2 ++ .../test/resources/TestBaseNoLineDelimiter.txt | 1 + 5 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 cobigen/cobigen-textmerger/src/test/resources/MergedBaseNoLineDelimiter.txt create mode 100644 cobigen/cobigen-textmerger/src/test/resources/PatchBaseNoLineDelimiter.txt create mode 100644 cobigen/cobigen-textmerger/src/test/resources/TestBaseNoLineDelimiter.txt diff --git a/cobigen/cobigen-textmerger/src/main/java/com/devonfw/cobigen/textmerger/TextAppender.java b/cobigen/cobigen-textmerger/src/main/java/com/devonfw/cobigen/textmerger/TextAppender.java index e2ba0bafca..ccf123352c 100644 --- a/cobigen/cobigen-textmerger/src/main/java/com/devonfw/cobigen/textmerger/TextAppender.java +++ b/cobigen/cobigen-textmerger/src/main/java/com/devonfw/cobigen/textmerger/TextAppender.java @@ -77,22 +77,22 @@ public String merge(File base, String patch, String targetCharset) throws MergeE String mergedString; String lineDelimiterBase; - Path path = Paths.get(base.getAbsolutePath()); + Path basePath = Paths.get(base.getAbsolutePath()); try { mergedString = FileUtils.readFileToString(base, targetCharset); - lineDelimiterBase = SystemUtil.determineLineDelimiter(path, targetCharset); + lineDelimiterBase = SystemUtil.determineLineDelimiter(basePath, targetCharset); } catch (IOException e) { throw new MergeException(base, "Could not read base file.", e); } try { - if (lineDelimiterBase.isEmpty()) { - lineDelimiterBase = System.lineSeparator(); + if (lineDelimiterBase == null) { + mergedString = merge(mergedString, patch, lineDelimiterBase); + } else { + mergedString = + merge(mergedString, StringUtil.consolidateLineEndings(patch, lineDelimiterBase), lineDelimiterBase); } - - mergedString = - merge(mergedString, StringUtil.consolidateLineEndings(patch, lineDelimiterBase), lineDelimiterBase); } catch (Exception e) { throw new MergeException(base, e.getMessage(), e); } diff --git a/cobigen/cobigen-textmerger/src/test/java/com/devonfw/cobigen/textmerger/TextAppenderTest.java b/cobigen/cobigen-textmerger/src/test/java/com/devonfw/cobigen/textmerger/TextAppenderTest.java index c3562a4401..cb80dd85fd 100644 --- a/cobigen/cobigen-textmerger/src/test/java/com/devonfw/cobigen/textmerger/TextAppenderTest.java +++ b/cobigen/cobigen-textmerger/src/test/java/com/devonfw/cobigen/textmerger/TextAppenderTest.java @@ -316,6 +316,21 @@ public void testMerge_normalizeToBaseLineDelimiter() throws Exception { .isEqualTo(FileUtils.readFileToString(new File(testFileRootPath + "MergedBaseLineDelimiter.txt"))); } + /** + * Tests if a merge of a base file without line endings with a patch file with line endings will create a + * valid result + * @throws Exception + * if errors occur while merging + */ + @Test + public void testMerge_noBaseLineDelimiterToConsolidate() throws Exception { + TextAppender appender = new TextAppender("textmerge_append", false); + String mergedString = appender.merge(new File(testFileRootPath + "TestBaseNoLineDelimiter.txt"), + FileUtils.readFileToString(new File(testFileRootPath + "PatchBaseNoLineDelimiter.txt")), "UTF-8"); + assertThat(mergedString) + .isEqualTo(FileUtils.readFileToString(new File(testFileRootPath + "MergedBaseNoLineDelimiter.txt"))); + } + /** * Helper method that creates a String matching the usual look of a merge exception * @param base diff --git a/cobigen/cobigen-textmerger/src/test/resources/MergedBaseNoLineDelimiter.txt b/cobigen/cobigen-textmerger/src/test/resources/MergedBaseNoLineDelimiter.txt new file mode 100644 index 0000000000..9bfeb69237 --- /dev/null +++ b/cobigen/cobigen-textmerger/src/test/resources/MergedBaseNoLineDelimiter.txt @@ -0,0 +1,2 @@ +ab +c \ No newline at end of file diff --git a/cobigen/cobigen-textmerger/src/test/resources/PatchBaseNoLineDelimiter.txt b/cobigen/cobigen-textmerger/src/test/resources/PatchBaseNoLineDelimiter.txt new file mode 100644 index 0000000000..588234ab44 --- /dev/null +++ b/cobigen/cobigen-textmerger/src/test/resources/PatchBaseNoLineDelimiter.txt @@ -0,0 +1,2 @@ +b +c \ No newline at end of file diff --git a/cobigen/cobigen-textmerger/src/test/resources/TestBaseNoLineDelimiter.txt b/cobigen/cobigen-textmerger/src/test/resources/TestBaseNoLineDelimiter.txt new file mode 100644 index 0000000000..2e65efe2a1 --- /dev/null +++ b/cobigen/cobigen-textmerger/src/test/resources/TestBaseNoLineDelimiter.txt @@ -0,0 +1 @@ +a \ No newline at end of file From 3bf45be8bb29e87631c73d4956459630c32a306e Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Thu, 17 Dec 2020 10:52:09 +0100 Subject: [PATCH 3/5] #1302 set release snapshot version --- cobigen/cobigen-textmerger/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen/cobigen-textmerger/pom.xml b/cobigen/cobigen-textmerger/pom.xml index 7b40cc9a8f..e8af865d18 100644 --- a/cobigen/cobigen-textmerger/pom.xml +++ b/cobigen/cobigen-textmerger/pom.xml @@ -2,7 +2,7 @@ 4.0.0 textmerger jar - 7.2.0-SNAPSHOT + 7.1.1-SNAPSHOT CobiGen - Text Merger Plug-in CobiGen - Text Merger Plug-in From 5b38c113251507450361749ec61bc0d6bcdcb137 Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Thu, 17 Dec 2020 10:52:47 +0100 Subject: [PATCH 4/5] #1302 update wiki docs --- documentation/master-cobigen.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/master-cobigen.asciidoc b/documentation/master-cobigen.asciidoc index 4c5aaea75b..30b507c059 100644 --- a/documentation/master-cobigen.asciidoc +++ b/documentation/master-cobigen.asciidoc @@ -22,7 +22,7 @@ DISCLAIMER: All Cobigen plugins are compatible with the latest release of Devonf * CobiGen - XML Plug-in v4.2.0 * CobiGen - TypeScript Plug-in v2.4.4 * CobiGen - Property Plug-in v2.1.0 -* CobiGen - Text Merger v7.1.0 +* CobiGen - Text Merger v7.1.1 * CobiGen - JSON Plug-in v2.1.0 * CobiGen - HTML Plug-in v2.1.0 * CobiGen - Open API Plug-in v2.4.0 From afccf6da5fe965a3749089a278bffdcf388dc912 Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Thu, 17 Dec 2020 10:52:50 +0100 Subject: [PATCH 5/5] #1302 Set release version --- cobigen/cobigen-textmerger/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen/cobigen-textmerger/pom.xml b/cobigen/cobigen-textmerger/pom.xml index e8af865d18..8e53b6c82f 100644 --- a/cobigen/cobigen-textmerger/pom.xml +++ b/cobigen/cobigen-textmerger/pom.xml @@ -2,7 +2,7 @@ 4.0.0 textmerger jar - 7.1.1-SNAPSHOT + 7.1.1 CobiGen - Text Merger Plug-in CobiGen - Text Merger Plug-in