From 6c91ef68df524276e7fe6bb215f296f67baf85f3 Mon Sep 17 00:00:00 2001 From: wumpz Date: Mon, 14 Aug 2017 09:21:33 +0200 Subject: [PATCH 01/16] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1402951f..2c86f6a7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.java-diff-utils diffutils jar - 2.0 + 2.1-SNAPSHOT java-diff-utils The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. From 1107f43f3683fe4e4d1f27969953c2df8a3aa7fd Mon Sep 17 00:00:00 2001 From: wumpz Date: Fri, 18 Aug 2017 14:48:35 +0200 Subject: [PATCH 02/16] fixes #11 --- .../github/difflib/text/DiffRowGenerator.java | 87 ++++++++++++------- .../difflib/text/DiffRowGeneratorTest.java | 32 +++++++ 2 files changed, 87 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java index b6d8db9d..aa678776 100644 --- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java +++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java @@ -35,10 +35,9 @@ import java.util.regex.Pattern; /** - * This class for generating DiffRows for side-by-sidy view. You can customize the way of - * generating. For example, show inline diffs on not, ignoring white spaces or/and blank lines and - * so on. All parameters for generating are optional. If you do not specify them, the class will use - * the default values. + * This class for generating DiffRows for side-by-sidy view. You can customize the way of generating. For example, show + * inline diffs on not, ignoring white spaces or/and blank lines and so on. All parameters for generating are optional. + * If you do not specify them, the class will use the default values. * * These values are: showInlineDiffs = false; ignoreWhiteSpaces = true; ignoreBlankLines = true; ... * @@ -49,9 +48,9 @@ */ public class DiffRowGenerator { - public static final BiPredicate IGNORE_WHITESPACE_EQUALIZER = (original, revised) + public static final BiPredicate IGNORE_WHITESPACE_EQUALIZER = (original, revised) -> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " ")); - public static final BiPredicate DEFAULT_EQUALIZER = Object::equals; + public static final BiPredicate DEFAULT_EQUALIZER = Object::equals; private static final Pattern SPLIT_PATTERN = Pattern.compile("\\s+|[,.\\[\\](){}/\\\\*+\\-#]"); private final boolean showInlineDiffs; private final boolean ignoreWhiteSpaces; @@ -61,6 +60,7 @@ public class DiffRowGenerator { private final int columnWidth; private final BiPredicate equalizer; private final boolean mergeOriginalRevised; + private final boolean reportLinesUnchanged; /** * This class used for building the DiffRowGenerator. @@ -79,6 +79,7 @@ public static class Builder { private int columnWidth = 80; private boolean mergeOriginalRevised = false; private boolean inlineDiffByWord = false; + private boolean reportLinesUnchanged = false; private Builder() { } @@ -105,6 +106,17 @@ public Builder ignoreWhiteSpaces(boolean val) { return this; } + /** + * Give the originial old and new text lines to Diffrow without any additional processing. + * + * @param val the value to set. Default: false. + * @return builder with configured reportLinesUnWrapped parameter + */ + public Builder reportLinesUnchanged(final boolean val) { + reportLinesUnchanged = val; + return this; + } + /** * Generator for Old-Text-Tags. * @@ -130,8 +142,8 @@ public Builder newTag(Function generator) { /** * Set the column with of generated lines of original and revised texts. * - * @param width the width to set. Making it < 0 doesn't have any sense. Default 80. @return - * builder with config ured ignoreBlankLines parameter + * @param width the width to set. Making it < 0 doesn't have any sense. Default 80. @return builder with config + * ured ignoreBlankLines parameter */ public Builder columnWidth(int width) { if (width > 0) { @@ -150,8 +162,7 @@ public DiffRowGenerator build() { } /** - * Merge the complete result within the original text. This makes sense for one line - * display. + * Merge the complete result within the original text. This makes sense for one line display. * * @param mergeOriginalRevised * @return @@ -162,8 +173,8 @@ public Builder mergeOriginalRevised(boolean mergeOriginalRevised) { } /** - * Per default each character is separatly processed. This variant introduces processing by - * word, which should deliver no in word changes. + * Per default each character is separatly processed. This variant introduces processing by word, which should + * deliver no in word changes. */ public Builder inlineDiffByWord(boolean inlineDiffByWord) { this.inlineDiffByWord = inlineDiffByWord; @@ -174,7 +185,7 @@ public Builder inlineDiffByWord(boolean inlineDiffByWord) { public static Builder create() { return new Builder(); } - + private DiffRowGenerator(Builder builder) { showInlineDiffs = builder.showInlineDiffs; ignoreWhiteSpaces = builder.ignoreWhiteSpaces; @@ -183,12 +194,13 @@ private DiffRowGenerator(Builder builder) { columnWidth = builder.columnWidth; mergeOriginalRevised = builder.mergeOriginalRevised; inlineDiffByWord = builder.inlineDiffByWord; - equalizer = ignoreWhiteSpaces?IGNORE_WHITESPACE_EQUALIZER:DEFAULT_EQUALIZER; + equalizer = ignoreWhiteSpaces ? IGNORE_WHITESPACE_EQUALIZER : DEFAULT_EQUALIZER; + reportLinesUnchanged = builder.reportLinesUnchanged; } /** - * Get the DiffRows describing the difference between original and revised texts using the given - * patch. Useful for displaying side-by-side diff. + * Get the DiffRows describing the difference between original and revised texts using the given patch. Useful for + * displaying side-by-side diff. * * @param original the original text * @param revised the revised text @@ -198,22 +210,34 @@ public List generateDiffRows(List original, List revise return generateDiffRows(original, DiffUtils.diff(original, revised, equalizer)); } + private String preprocessLine(String line) { + if (columnWidth == 0) { + return StringUtils.normalize(line); + } else { + return StringUtils.wrapText(StringUtils.normalize(line), columnWidth); + } + } + private DiffRow buildDiffRow(Tag type, String orgline, String newline) { - String wrapOrg = StringUtils.wrapText(StringUtils.normalize(orgline), columnWidth); - if (Tag.DELETE == type) { - if (mergeOriginalRevised || showInlineDiffs) { - wrapOrg = oldTag.apply(true) + wrapOrg + oldTag.apply(false); + if (reportLinesUnchanged) { + return new DiffRow(type, orgline, newline); + } else { + String wrapOrg = preprocessLine(orgline); + if (Tag.DELETE == type) { + if (mergeOriginalRevised || showInlineDiffs) { + wrapOrg = oldTag.apply(true) + wrapOrg + oldTag.apply(false); + } } - } - String wrapNew = StringUtils.wrapText(StringUtils.normalize(newline), columnWidth); - if (Tag.INSERT == type) { - if (mergeOriginalRevised) { - wrapOrg = newTag.apply(true) + wrapNew + newTag.apply(false); - } else if (showInlineDiffs) { - wrapNew = newTag.apply(true) + wrapNew + newTag.apply(false); + String wrapNew = preprocessLine(newline); + if (Tag.INSERT == type) { + if (mergeOriginalRevised) { + wrapOrg = newTag.apply(true) + wrapNew + newTag.apply(false); + } else if (showInlineDiffs) { + wrapNew = newTag.apply(true) + wrapNew + newTag.apply(false); + } } + return new DiffRow(type, wrapOrg, wrapNew); } - return new DiffRow(type, wrapOrg, wrapNew); } private DiffRow buildDiffRowWithoutNormalizing(Tag type, String orgline, String newline) { @@ -223,8 +247,8 @@ private DiffRow buildDiffRowWithoutNormalizing(Tag type, String orgline, String } /** - * Generates the DiffRows describing the difference between original and revised texts using the - * given patch. Useful for displaying side-by-side diff. + * Generates the DiffRows describing the difference between original and revised texts using the given patch. Useful + * for displaying side-by-side diff. * * @param original the original text * @param revised the revised text @@ -367,8 +391,7 @@ private List generateInlineDiffs(Delta delta) throws DiffExcept /** * Wrap the elements in the sequence with the given tag * - * @param startPosition the position from which tag should start. The counting start from a - * zero. + * @param startPosition the position from which tag should start. The counting start from a zero. * @param endPosition the position before which tag should should be closed. * @param tag the tag name without angle brackets, just a word * @param cssClass the optional css class diff --git a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java index a7ddc3d3..867b8c31 100644 --- a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java +++ b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java @@ -24,6 +24,20 @@ public void testGenerator_Default() throws DiffException { assertEquals(3, rows.size()); } + + @Test + public void testGenerator_Default2() throws DiffException { + String first = "anything \n \nother"; + String second = "anything\n\nother"; + + DiffRowGenerator generator = DiffRowGenerator.create() + .columnWidth(0) // do not wrap + .build(); + List rows = generator.generateDiffRows(split(first), split(second)); + print(rows); + + assertEquals(3, rows.size()); + } @Test public void testGenerator_InlineDiff() throws DiffException { @@ -232,4 +246,22 @@ public void testGeneratorExample2() throws DiffException { assertEquals("This is a test ~senctence~.", rows.get(0).getOldLine()); assertEquals("This is a test **for diffutils**.", rows.get(0).getNewLine()); } + + @Test + public void testGeneratorUnchanged() throws DiffException { + String first = "anything \n \nother"; + String second = "anything\n\nother"; + + DiffRowGenerator generator = DiffRowGenerator.create() + .columnWidth(5) + .reportLinesUnchanged(true) + .build(); + List rows = generator.generateDiffRows(split(first), split(second)); + print(rows); + + assertEquals(3, rows.size()); + assertEquals("[CHANGE,anything ,anything]", rows.get(0).toString()); + assertEquals("[CHANGE, ,]", rows.get(1).toString()); + assertEquals("[EQUAL,other,other]", rows.get(2).toString()); + } } From 5d5218ba30104ab90b0e2306a7b4e5c6347389c4 Mon Sep 17 00:00:00 2001 From: wumpz Date: Fri, 18 Aug 2017 14:50:32 +0200 Subject: [PATCH 03/16] fixes #11 --- src/main/java/com/github/difflib/text/DiffRowGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java index aa678776..2362d132 100644 --- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java +++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java @@ -146,7 +146,7 @@ public Builder newTag(Function generator) { * ured ignoreBlankLines parameter */ public Builder columnWidth(int width) { - if (width > 0) { + if (width >= 0) { columnWidth = width; } return this; From aed1d31c2b907c6ad6ccdc65b7c22db029269d32 Mon Sep 17 00:00:00 2001 From: wumpz Date: Wed, 30 Aug 2017 13:46:55 +0200 Subject: [PATCH 04/16] --- src/main/java/com/github/difflib/DiffUtils.java | 6 +++--- .../java/com/github/difflib/patch/Patch.java | 17 ++++++++++++----- .../github/difflib/text/DiffRowGenerator.java | 14 ++++++++------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/github/difflib/DiffUtils.java b/src/main/java/com/github/difflib/DiffUtils.java index 9a8a3d2d..c0a7a74c 100644 --- a/src/main/java/com/github/difflib/DiffUtils.java +++ b/src/main/java/com/github/difflib/DiffUtils.java @@ -25,9 +25,9 @@ import com.github.difflib.patch.Delta; import com.github.difflib.patch.Patch; import com.github.difflib.patch.PatchFailedException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.function.BiPredicate; @@ -111,8 +111,8 @@ public static Patch diff(List original, List revised, * @return */ public static Patch diffInline(String original, String revised) throws DiffException { - LinkedList origList = new LinkedList<>(); - LinkedList revList = new LinkedList<>(); + List origList = new ArrayList<>(); + List revList = new ArrayList<>(); for (Character character : original.toCharArray()) { origList.add(character.toString()); } diff --git a/src/main/java/com/github/difflib/patch/Patch.java b/src/main/java/com/github/difflib/patch/Patch.java index 2605b82b..4d2f2e4d 100644 --- a/src/main/java/com/github/difflib/patch/Patch.java +++ b/src/main/java/com/github/difflib/patch/Patch.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Collections; import static java.util.Comparator.comparing; -import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@ -37,8 +36,16 @@ */ public final class Patch { - private final List> deltas = new LinkedList<>(); + private final List> deltas; + public Patch() { + this(10); + } + + public Patch(int estimatedPatchSize) { + deltas = new ArrayList<>(estimatedPatchSize); + } + /** * Apply this patch to the given target * @@ -46,7 +53,7 @@ public final class Patch { * @throws PatchFailedException if can't apply patch */ public List applyTo(List target) throws PatchFailedException { - List result = new LinkedList<>(target); + List result = new ArrayList<>(target); ListIterator> it = getDeltas().listIterator(deltas.size()); while (it.hasPrevious()) { Delta delta = it.previous(); @@ -62,7 +69,7 @@ public List applyTo(List target) throws PatchFailedException { * @return the restored text */ public List restore(List target) { - List result = new LinkedList<>(target); + List result = new ArrayList<>(target); ListIterator> it = getDeltas().listIterator(deltas.size()); while (it.hasPrevious()) { Delta delta = it.previous(); @@ -96,7 +103,7 @@ public String toString() { } public static Patch generate(List original, List revised, List changes) { - Patch patch = new Patch<>(); + Patch patch = new Patch<>(changes.size()); for (Change change : changes) { Chunk orgChunk = new Chunk<>(change.startOriginal, new ArrayList<>(original.subList(change.startOriginal, change.endOriginal))); Chunk revChunk = new Chunk<>(change.startRevised, new ArrayList<>(revised.subList(change.startRevised, change.endRevised))); diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java index 2362d132..16ca767a 100644 --- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java +++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java @@ -315,17 +315,19 @@ private List generateInlineDiffs(Delta delta) throws DiffExcept List rev = StringUtils.normalize(delta.getRevised().getLines()); List origList; List revList; + String joinedOrig = String.join("\n", orig); + String joinedRev = String.join("\n", rev); if (inlineDiffByWord) { - origList = splitStringPreserveDelimiter(String.join("\n", orig)); - revList = splitStringPreserveDelimiter(String.join("\n", rev)); + origList = splitStringPreserveDelimiter(joinedOrig); + revList = splitStringPreserveDelimiter(joinedRev); } else { - origList = new LinkedList<>(); - revList = new LinkedList<>(); - for (Character character : String.join("\n", orig).toCharArray()) { + origList = new ArrayList<>(joinedOrig.length()); + revList = new ArrayList<>(joinedRev.length()); + for (Character character : joinedOrig.toCharArray()) { origList.add(character.toString()); } - for (Character character : String.join("\n", rev).toCharArray()) { + for (Character character : joinedRev.toCharArray()) { revList.add(character.toString()); } } From 88146c6afbc15cb404d4e8f8310dd2ea4a4628c0 Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 28 Sep 2017 13:25:54 +0200 Subject: [PATCH 05/16] make columnwith 0, meaning no text wrap, the standard --- .../java/com/github/difflib/text/DiffRowGenerator.java | 2 +- src/main/java/com/github/difflib/text/StringUtils.java | 7 +++++-- .../java/com/github/difflib/text/DiffRowGeneratorTest.java | 1 + src/test/java/com/github/difflib/text/StringUtilsTest.java | 3 +-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java index 16ca767a..e25e9286 100644 --- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java +++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java @@ -76,7 +76,7 @@ public static class Builder { private Function oldTag = f -> f ? "" : ""; private Function newTag = f -> f ? "" : ""; - private int columnWidth = 80; + private int columnWidth = 0; private boolean mergeOriginalRevised = false; private boolean inlineDiffByWord = false; private boolean reportLinesUnchanged = false; diff --git a/src/main/java/com/github/difflib/text/StringUtils.java b/src/main/java/com/github/difflib/text/StringUtils.java index 13673345..4166b311 100644 --- a/src/main/java/com/github/difflib/text/StringUtils.java +++ b/src/main/java/com/github/difflib/text/StringUtils.java @@ -58,8 +58,11 @@ public static List wrapText(List list, int columnWidth) { * @return the wrapped text */ public static String wrapText(String line, int columnWidth) { - if (columnWidth <= 0) { - throw new IllegalArgumentException("columnWidth may not be less or equal 0"); + if (columnWidth < 0) { + throw new IllegalArgumentException("columnWidth may not be less 0"); + } + if (columnWidth == 0) { + return line; } int length = line.length(); int delimiter = "
".length(); diff --git a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java index 867b8c31..616c189e 100644 --- a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java +++ b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java @@ -173,6 +173,7 @@ public void testGeneratorWithMergeByWord5() throws DiffException { .showInlineDiffs(true) .mergeOriginalRevised(true) .inlineDiffByWord(true) + .columnWidth(80) .build(); List rows = generator.generateDiffRows(Arrays.asList("Test feature"),Arrays.asList("ester feature best")); print(rows); diff --git a/src/test/java/com/github/difflib/text/StringUtilsTest.java b/src/test/java/com/github/difflib/text/StringUtilsTest.java index 12074363..ad8f1db2 100644 --- a/src/test/java/com/github/difflib/text/StringUtilsTest.java +++ b/src/test/java/com/github/difflib/text/StringUtilsTest.java @@ -15,7 +15,6 @@ */ package com.github.difflib.text; -import com.github.difflib.text.StringUtils; import java.util.Collections; import org.junit.Test; import static org.junit.Assert.*; @@ -62,7 +61,7 @@ public void testWrapText_String_int() { @Test(expected = IllegalArgumentException.class) public void testWrapText_String_int_zero() { - assertEquals("test", StringUtils.wrapText("test", 0)); + assertEquals("test", StringUtils.wrapText("test", -1)); } } From e6fa5938a9a3b3f55adc0cec45e7183c4802412e Mon Sep 17 00:00:00 2001 From: wumpz Date: Wed, 25 Oct 2017 08:49:20 +0200 Subject: [PATCH 06/16] included checkstyle source code conventions --- README.md | 22 + java-diff-utils.iml | 58 +-- nb-configuration.xml | 38 +- pom.xml | 451 ++++++++++-------- .../java/com/github/difflib/DiffUtils.java | 39 +- .../com/github/difflib/UnifiedDiffUtils.java | 16 +- .../com/github/difflib/algorithm/Change.java | 1 + .../difflib/algorithm/DiffAlgorithm.java | 8 +- .../DifferentiationFailedException.java | 7 +- .../difflib/algorithm/jgit/HistogramDiff.java | 15 +- .../difflib/algorithm/myers/MyersDiff.java | 18 +- .../difflib/algorithm/myers/PathNode.java | 11 +- .../java/com/github/difflib/patch/Chunk.java | 7 +- .../com/github/difflib/patch/DeleteDelta.java | 2 +- .../java/com/github/difflib/patch/Delta.java | 2 +- .../com/github/difflib/patch/DeltaType.java | 3 +- .../com/github/difflib/patch/InsertDelta.java | 2 +- .../java/com/github/difflib/patch/Patch.java | 10 +- .../java/com/github/difflib/text/DiffRow.java | 3 +- .../github/difflib/text/DiffRowGenerator.java | 2 +- .../com/github/difflib/DiffUtilsTest.java | 15 +- .../difflib/GenerateUnifiedDiffTest.java | 2 - .../com/github/difflib/TestConstants.java | 1 + .../algorithm/jgit/HistogramDiffTest.java | 23 +- .../algorithm/jgit/LRHistogramDiffTest.java | 23 +- .../algorithm/myers/MyersDiffTest.java | 8 +- .../com/github/difflib/patch/PatchTest.java | 2 - .../difflib/text/DiffRowGeneratorTest.java | 49 +- .../github/difflib/text/StringUtilsTest.java | 10 +- 29 files changed, 445 insertions(+), 403 deletions(-) diff --git a/README.md b/README.md index 9b55899f..ca9f2979 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ This is a test ~senctence~**for diffutils**. But it can easily replaced by any other which is better for handing your texts. I have plan to add implementation of some in future. ### Changelog ### + * Version 2.1-SNAPSHOT + * included checkstyle source code conventions * Version 2.0 * switch to maven and removed other artifacts * changed groupid to **com.github.java-diff-utils** due to different forks at github @@ -66,6 +68,26 @@ But it can easily replaced by any other which is better for handing your texts. * Ant build script * Generate output in unified diff format (thanks for Bill James) +## Source Code conventions + +Recently a checkstyle process was integrated into the build process. JSqlParser follows the sun java format convention. There are no TABs allowed. Use spaces. + +```java +public static Patch diff(List original, List revised, + BiPredicate equalizer) throws DiffException { + if (equalizer != null) { + return DiffUtils.diff(original, revised, + new MyersDiff<>(equalizer)); + } + return DiffUtils.diff(original, revised, new MyersDiff<>()); +} +``` + +This is a valid piece of source code: +* blocks without braces are not allowed +* after control statements (if, while, for) a whitespace is expected +* the opening brace should be in the same line as the control statement + ### To Install ### **This jar is not yet to get at maven central.** diff --git a/java-diff-utils.iml b/java-diff-utils.iml index 5f6b53a8..1dc1f4d5 100644 --- a/java-diff-utils.iml +++ b/java-diff-utils.iml @@ -1,29 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nb-configuration.xml b/nb-configuration.xml index f1692631..f5e3165a 100644 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -1,22 +1,22 @@ - - - - none - false - true - LF - false - + + + + none + false + true + LF + false + diff --git a/pom.xml b/pom.xml index 2c86f6a7..c15a9a96 100644 --- a/pom.xml +++ b/pom.xml @@ -1,213 +1,272 @@ - 4.0.0 - com.github.java-diff-utils - diffutils - jar - 2.1-SNAPSHOT + 4.0.0 + com.github.java-diff-utils + diffutils + jar + 2.1-SNAPSHOT - java-diff-utils - The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. - https://github.com/wumpz/java-diff-utils - 2009 + java-diff-utils + The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. + https://github.com/wumpz/java-diff-utils + 2009 - - scm:git:https://github.com/wumpz/java-diff-utils.git - scm:git:ssh://git@github.com:wumpz/java-diff-utils.git - https://github.com/wumpz/java-diff-utils.git - diffutils-2.0 - + + scm:git:https://github.com/wumpz/java-diff-utils.git + scm:git:ssh://git@github.com:wumpz/java-diff-utils.git + https://github.com/wumpz/java-diff-utils.git + diffutils-2.0 + - - GitHub Issues - https://github.com/wumpz/java-diff-utils/issues - + + GitHub Issues + https://github.com/wumpz/java-diff-utils/issues + - - java-diff-utils - + + java-diff-utils + - - - Tobias Warneke - t.warneke@gmx.net - - - Dmitry Naumenko - dm.naumenko@gmail.com - - - Juanco Anez - juanco@suigeneris.org - - + + + Tobias Warneke + t.warneke@gmx.net + + + Dmitry Naumenko + dm.naumenko@gmail.com + + + Juanco Anez + juanco@suigeneris.org + + - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - A business-friendly OSS license - - + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + A business-friendly OSS license + + - - UTF-8 - + + UTF-8 + - - - junit - junit - 4.12 - jar - test - - - org.eclipse.jgit - org.eclipse.jgit - 4.4.1.201607150455-r - - - com.googlecode.javaewah - JavaEWAH - - - commons-codec - commons-codec - - - commons-logging - commons-logging - - - org.apache.httpcomponents - httpclient - - - com.jcraft - jsch - - - org.slf4j - slf4j-api - - - - + + + junit + junit + 4.12 + jar + test + + + org.eclipse.jgit + org.eclipse.jgit + 4.4.1.201607150455-r + + + com.googlecode.javaewah + JavaEWAH + + + commons-codec + commons-codec + + + commons-logging + commons-logging + + + org.apache.httpcomponents + httpclient + + + com.jcraft + jsch + + + org.slf4j + slf4j-api + + + + - - + + - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - UTF-8 - - + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + UTF-8 + + - - - - maven-jar-plugin - 3.0.2 - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - 3.3.0 - - - bundle-manifest - process-classes - - manifest - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - ${javadoc.opts} - - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - - - **/LR*.java - - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - true - false - forked-path + + + + maven-jar-plugin + 3.0.2 + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + org.apache.felix + maven-bundle-plugin + 3.3.0 + + + bundle-manifest + process-classes + + manifest + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + ${javadoc.opts} + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + **/LR*.java + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + true + false + forked-path install - - - - - - - doclint-java8-disable - - [1.8,) - - - -Xdoclint:none - - - - long-running-tests - - - - org.apache.maven.plugins - maven-surefire-plugin - - - xxx - - - - - - - + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.17 + + + verify-style + process-classes + + check + + + + + true + true + ${project.build.sourceDirectory} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.puppycrawl.tools + checkstyle + 6.19 + + + + + + + + doclint-java8-disable + + [1.8,) + + + -Xdoclint:none + + + + long-running-tests + + + + org.apache.maven.plugins + maven-surefire-plugin + + + xxx + + + + + + + diff --git a/src/main/java/com/github/difflib/DiffUtils.java b/src/main/java/com/github/difflib/DiffUtils.java index c0a7a74c..807d7b4a 100644 --- a/src/main/java/com/github/difflib/DiffUtils.java +++ b/src/main/java/com/github/difflib/DiffUtils.java @@ -42,18 +42,16 @@ public final class DiffUtils { /** - * Computes the difference between the original and revised list of elements with default diff - * algorithm + * Computes the difference between the original and revised list of elements with default diff algorithm * * @param original The original text. Must not be {@code null}. * @param revised The revised text. Must not be {@code null}. - * @return The patch describing the difference between the original and revised sequences. Never - * {@code null}. + * @return The patch describing the difference between the original and revised sequences. Never {@code null}. */ public static Patch diff(List original, List revised) throws DiffException { return DiffUtils.diff(original, revised, new MyersDiff<>()); } - + /** * Computes the difference between the original and revised text. */ @@ -62,19 +60,17 @@ public static Patch diff(String originalText, String revisedText) throws } /** - * Computes the difference between the original and revised list of elements with default diff - * algorithm + * Computes the difference between the original and revised list of elements with default diff algorithm * * @param original The original text. Must not be {@code null}. * @param revised The revised text. Must not be {@code null}. * - * @param equalizer the equalizer object to replace the default compare algorithm - * (Object.equals). If {@code null} the default equalizer of the default algorithm is used.. - * @return The patch describing the difference between the original and revised sequences. Never - * {@code null}. + * @param equalizer the equalizer object to replace the default compare algorithm (Object.equals). If {@code null} + * the default equalizer of the default algorithm is used.. + * @return The patch describing the difference between the original and revised sequences. Never {@code null}. */ public static Patch diff(List original, List revised, - BiPredicate equalizer) throws DiffException { + BiPredicate equalizer) throws DiffException { if (equalizer != null) { return DiffUtils.diff(original, revised, new MyersDiff<>(equalizer)); @@ -83,28 +79,25 @@ public static Patch diff(List original, List revised, } /** - * Computes the difference between the original and revised list of elements with default diff - * algorithm + * Computes the difference between the original and revised list of elements with default diff algorithm * * @param original The original text. Must not be {@code null}. * @param revised The revised text. Must not be {@code null}. * @param algorithm The diff algorithm. Must not be {@code null}. - * @return The patch describing the difference between the original and revised sequences. Never - * {@code null}. + * @return The patch describing the difference between the original and revised sequences. Never {@code null}. */ public static Patch diff(List original, List revised, DiffAlgorithm algorithm) throws DiffException { - Objects.requireNonNull(original,"original must not be null"); - Objects.requireNonNull(revised,"revised must not be null"); - Objects.requireNonNull(algorithm,"algorithm must not be null"); - + Objects.requireNonNull(original, "original must not be null"); + Objects.requireNonNull(revised, "revised must not be null"); + Objects.requireNonNull(algorithm, "algorithm must not be null"); + return Patch.generate(original, revised, algorithm.diff(original, revised)); } /** - * Computes the difference between the given texts inline. This one uses the "trick" to make out - * of texts lists of characters, like DiffRowGenerator does and merges those changes at the end - * together again. + * Computes the difference between the given texts inline. This one uses the "trick" to make out of texts lists of + * characters, like DiffRowGenerator does and merges those changes at the end together again. * * @param original * @param revised diff --git a/src/main/java/com/github/difflib/UnifiedDiffUtils.java b/src/main/java/com/github/difflib/UnifiedDiffUtils.java index c48b050f..1395c795 100644 --- a/src/main/java/com/github/difflib/UnifiedDiffUtils.java +++ b/src/main/java/com/github/difflib/UnifiedDiffUtils.java @@ -29,6 +29,7 @@ * @author toben */ public final class UnifiedDiffUtils { + private static final Pattern UNIFIED_DIFF_CHUNK_REGEXP = Pattern .compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$"); @@ -124,10 +125,10 @@ public static Patch parseUnifiedDiff(List diff) { return patch; } - + /** - * generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format - * text representing the Patch. + * generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing + * the Patch. * * @param original - Filename of the original (unrevised file) * @param revised - Filename of the revised file @@ -195,10 +196,9 @@ public static List generateUnifiedDiff(String original, } return new ArrayList<>(); } - + /** - * processDeltas takes a list of Deltas and outputs them together in a single block of - * Unified-Diff-format text. + * processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text. * * @param origLines - the lines of the original file * @param deltas - the Deltas to be output as a single block @@ -289,7 +289,7 @@ private static List processDeltas(List origLines, return buffer; } - + /** * getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter * @@ -307,7 +307,7 @@ private static List getDeltaText(Delta delta) { } return buffer; } - + private UnifiedDiffUtils() { } } diff --git a/src/main/java/com/github/difflib/algorithm/Change.java b/src/main/java/com/github/difflib/algorithm/Change.java index eb21d3fe..b90e2022 100644 --- a/src/main/java/com/github/difflib/algorithm/Change.java +++ b/src/main/java/com/github/difflib/algorithm/Change.java @@ -22,6 +22,7 @@ * @author toben */ public class Change { + public final DeltaType deltaType; public final int startOriginal; public final int endOriginal; diff --git a/src/main/java/com/github/difflib/algorithm/DiffAlgorithm.java b/src/main/java/com/github/difflib/algorithm/DiffAlgorithm.java index e6a20151..b97a15a4 100644 --- a/src/main/java/com/github/difflib/algorithm/DiffAlgorithm.java +++ b/src/main/java/com/github/difflib/algorithm/DiffAlgorithm.java @@ -31,8 +31,8 @@ public interface DiffAlgorithm { /** - * Computes the difference between the original sequence and the revised sequence and returns it - * as a {@link Patch} object. + * Computes the difference between the original sequence and the revised sequence and returns it as a {@link Patch} + * object. * * @param original The original sequence. Must not be {@code null}. * @param revised The revised sequence. Must not be {@code null}. @@ -43,8 +43,8 @@ public default List diff(T[] original, T[] revised) throws DiffException } /** - * Computes the difference between the original sequence and the revised sequence and returns it - * as a {@link Patch} object. + * Computes the difference between the original sequence and the revised sequence and returns it as a {@link Patch} + * object. * * @param original The original sequence. Must not be {@code null}. * @param revised The revised sequence. Must not be {@code null}. diff --git a/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java b/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java index 132288f5..80c881e5 100644 --- a/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java +++ b/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java @@ -19,12 +19,9 @@ */ package com.github.difflib.algorithm; -import com.github.difflib.algorithm.DiffException; - /** - * Thrown whenever the differencing engine cannot produce the differences between two revisions of - * ta text. - + * Thrown whenever the differencing engine cannot produce the differences between two revisions of ta text. + * * @see MyersDiff * @see difflib.DiffAlgorithm */ diff --git a/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java b/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java index 978f56e9..6ca80103 100644 --- a/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java +++ b/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java @@ -28,9 +28,8 @@ import org.eclipse.jgit.diff.SequenceComparator; /** - * HistorgramDiff using JGit - Library. This one is much more performant than the - * orginal Myers implementation. - * + * HistorgramDiff using JGit - Library. This one is much more performant than the orginal Myers implementation. + * * @author toben */ public class HistogramDiff implements DiffAlgorithm { @@ -43,19 +42,19 @@ public List diff(List original, List revised) throws DiffException diffList.addAll(new org.eclipse.jgit.diff.HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised))); List patch = new ArrayList<>(); for (Edit edit : diffList) { - DeltaType type = DeltaType.EQUAL; + DeltaType type = DeltaType.EQUAL; switch (edit.getType()) { case DELETE: - type = DeltaType.DELETE; + type = DeltaType.DELETE; break; case INSERT: - type = DeltaType.INSERT; + type = DeltaType.INSERT; break; case REPLACE: - type = DeltaType.CHANGE; + type = DeltaType.CHANGE; break; } - patch.add(new Change(type,edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB())); + patch.add(new Change(type, edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB())); } return patch; } diff --git a/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java b/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java index 6907f681..ec76ec3f 100644 --- a/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java +++ b/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java @@ -20,9 +20,9 @@ package com.github.difflib.algorithm.myers; import com.github.difflib.algorithm.Change; -import com.github.difflib.algorithm.DifferentiationFailedException; import com.github.difflib.algorithm.DiffAlgorithm; import com.github.difflib.algorithm.DiffException; +import com.github.difflib.algorithm.DifferentiationFailedException; import com.github.difflib.patch.DeltaType; import com.github.difflib.patch.Patch; import java.util.ArrayList; @@ -35,16 +35,14 @@ */ public final class MyersDiff implements DiffAlgorithm { - private final BiPredicate DEFAULT_EQUALIZER = Object::equals; - private final BiPredicate equalizer; - + private final BiPredicate DEFAULT_EQUALIZER = Object::equals; + private final BiPredicate equalizer; public MyersDiff() { equalizer = DEFAULT_EQUALIZER; } - - public MyersDiff(final BiPredicate equalizer) { + public MyersDiff(final BiPredicate equalizer) { Objects.requireNonNull(equalizer, "equalizer must not be null"); this.equalizer = equalizer; } @@ -64,9 +62,8 @@ public List diff(final List original, final List revised) throws D } /** - * Computes the minimum diffpath that expresses de differences between the - * original and revised sequences, according to Gene Myers differencing - * algorithm. + * Computes the minimum diffpath that expresses de differences between the original and revised sequences, according + * to Gene Myers differencing algorithm. * * @param orig The original sequence. * @param rev The revised sequence. @@ -138,8 +135,7 @@ private PathNode buildPath(final List orig, final List rev) * @param orig The original sequence. * @param rev The revised sequence. * @return A {@link Patch} script corresponding to the path. - * @throws DifferentiationFailedException if a {@link Patch} could not be - * built from the given path. + * @throws DifferentiationFailedException if a {@link Patch} could not be built from the given path. */ private List buildRevision(PathNode actualPath, List orig, List rev) { Objects.requireNonNull(actualPath, "path is null"); diff --git a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java index c60b4829..01d669f7 100644 --- a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java +++ b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java @@ -44,7 +44,7 @@ public final class PathNode { public final PathNode prev; public final boolean snake; - + public final boolean bootstrap; /** @@ -61,7 +61,7 @@ public PathNode(int i, int j, boolean snake, boolean bootstrap, PathNode prev) { if (snake) { this.prev = prev; } else { - this.prev = (prev == null ? null : prev.previousSnake()); + this.prev = prev == null ? null : prev.previousSnake(); } this.snake = snake; } @@ -82,11 +82,10 @@ public boolean isBootstrap() { } /** - * Skips sequences of {@link DiffNode DiffNodes} until a {@link Snake} or bootstrap node is - * found, or the end of the path is reached. + * Skips sequences of {@link DiffNode DiffNodes} until a {@link Snake} or bootstrap node is found, or the end of the + * path is reached. * - * @return The next first {@link Snake} or bootstrap node in the path, or null if - * none found. + * @return The next first {@link Snake} or bootstrap node in the path, or null if none found. */ public final PathNode previousSnake() { if (isBootstrap()) { diff --git a/src/main/java/com/github/difflib/patch/Chunk.java b/src/main/java/com/github/difflib/patch/Chunk.java index 8b21e7b8..5855c3f1 100644 --- a/src/main/java/com/github/difflib/patch/Chunk.java +++ b/src/main/java/com/github/difflib/patch/Chunk.java @@ -26,10 +26,9 @@ * Holds the information about the part of text involved in the diff process * *

- * Text is represented as Object[] because the diff engine is capable of handling more - * than plain ascci. In fact, arrays or lists of any type that implements - * {@link java.lang.Object#hashCode hashCode()} and {@link java.lang.Object#equals equals()} - * correctly can be subject to differencing using this library. + * Text is represented as Object[] because the diff engine is capable of handling more than plain ascci. In + * fact, arrays or lists of any type that implements {@link java.lang.Object#hashCode hashCode()} and + * {@link java.lang.Object#equals equals()} correctly can be subject to differencing using this library. *

* * @author target) throws PatchFailedException { target.add(position + i, lines.get(i)); } } - + @Override public void restore(List target) { int position = getRevised().getPosition(); diff --git a/src/main/java/com/github/difflib/patch/Patch.java b/src/main/java/com/github/difflib/patch/Patch.java index 4d2f2e4d..ec7c357b 100644 --- a/src/main/java/com/github/difflib/patch/Patch.java +++ b/src/main/java/com/github/difflib/patch/Patch.java @@ -41,11 +41,11 @@ public final class Patch { public Patch() { this(10); } - + public Patch(int estimatedPatchSize) { - deltas = new ArrayList<>(estimatedPatchSize); + deltas = new ArrayList<>(estimatedPatchSize); } - + /** * Apply this patch to the given target * @@ -87,7 +87,7 @@ public void addDelta(Delta delta) { deltas.add(delta); } - /** + /** * Get the list of computed deltas * * @return the deltas @@ -101,7 +101,7 @@ public List> getDeltas() { public String toString() { return "Patch{" + "deltas=" + deltas + '}'; } - + public static Patch generate(List original, List revised, List changes) { Patch patch = new Patch<>(changes.size()); for (Change change : changes) { diff --git a/src/main/java/com/github/difflib/text/DiffRow.java b/src/main/java/com/github/difflib/text/DiffRow.java index f6ab5f5b..dd8cd9d6 100644 --- a/src/main/java/com/github/difflib/text/DiffRow.java +++ b/src/main/java/com/github/difflib/text/DiffRow.java @@ -22,8 +22,7 @@ import java.io.Serializable; /** - * Describes the diff row in form [tag, oldLine, newLine) for showing the difference between two - * texts + * Describes the diff row in form [tag, oldLine, newLine) for showing the difference between two texts * * @author Dmitry Naumenko */ diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java index e25e9286..ad13542b 100644 --- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java +++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java @@ -43,7 +43,7 @@ * * For instantiating the DiffRowGenerator you should use the its builder. Like in example * DiffRowGenerator generator = new DiffRowGenerator.Builder().showInlineDiffs(true). - * ignoreWhiteSpaces(true).columnWidth(100).build(); + * ignoreWhiteSpaces(true).columnWidth(100).build(); * */ public class DiffRowGenerator { diff --git a/src/test/java/com/github/difflib/DiffUtilsTest.java b/src/test/java/com/github/difflib/DiffUtilsTest.java index d8aa3cf1..d815401b 100644 --- a/src/test/java/com/github/difflib/DiffUtilsTest.java +++ b/src/test/java/com/github/difflib/DiffUtilsTest.java @@ -1,6 +1,5 @@ package com.github.difflib; -import com.github.difflib.DiffUtils; import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.ChangeDelta; import com.github.difflib.patch.Chunk; @@ -138,25 +137,25 @@ public void testDiffMissesChangeForkDnaumenkoIssue31() throws DiffException { @Ignore public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException { ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip"); - + Patch patch = DiffUtils.diff( - readStringListFromInputStream(zip.getInputStream(zip.getEntry("ta"))), + readStringListFromInputStream(zip.getInputStream(zip.getEntry("ta"))), readStringListFromInputStream(zip.getInputStream(zip.getEntry("tb")))); - + assertEquals(1, patch.getDeltas().size()); } - + public static List readStringListFromInputStream(InputStream is) throws IOException { try (BufferedReader reader = new BufferedReader( new InputStreamReader(is, Charset.forName(StandardCharsets.UTF_8.name())))) { - + return reader.lines().collect(toList()); } } - + @Test public void testDiffMyersExample1() throws DiffException { - final Patch patch = DiffUtils.diff(Arrays.asList("A","B","C","A","B","B","A"), Arrays.asList("C","B","A","B","A","C")); + final Patch patch = DiffUtils.diff(Arrays.asList("A", "B", "C", "A", "B", "B", "A"), Arrays.asList("C", "B", "A", "B", "A", "C")); assertNotNull(patch); assertEquals(4, patch.getDeltas().size()); assertEquals("Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [InsertDelta, position: 3, lines: [B]], [DeleteDelta, position: 5, lines: [B]], [InsertDelta, position: 7, lines: [C]]]}", patch.toString()); diff --git a/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java b/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java index 79ceec3e..89ab32f6 100644 --- a/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java +++ b/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java @@ -1,7 +1,5 @@ package com.github.difflib; -import com.github.difflib.DiffUtils; -import com.github.difflib.UnifiedDiffUtils; import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.Patch; import com.github.difflib.patch.PatchFailedException; diff --git a/src/test/java/com/github/difflib/TestConstants.java b/src/test/java/com/github/difflib/TestConstants.java index 7abb9a4d..56f5bf66 100644 --- a/src/test/java/com/github/difflib/TestConstants.java +++ b/src/test/java/com/github/difflib/TestConstants.java @@ -7,6 +7,7 @@ * */ public final class TestConstants { + public static final String BASE_FOLDER_RESOURCES = "target/test-classes/"; /** * The base folder containing the test files. Ends with {@link #FS}. diff --git a/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java b/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java index 1de65885..ec44adea 100644 --- a/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java +++ b/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java @@ -15,44 +15,39 @@ */ package com.github.difflib.algorithm.jgit; -import com.github.difflib.algorithm.jgit.HistogramDiff; -import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream; -import com.github.difflib.TestConstants; import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.Patch; import com.github.difflib.patch.PatchFailedException; -import java.io.IOException; import java.util.Arrays; import java.util.List; -import java.util.zip.ZipFile; import org.junit.After; import org.junit.AfterClass; +import static org.junit.Assert.*; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.*; /** * * @author toben */ public class HistogramDiffTest { - + public HistogramDiffTest() { } - + @BeforeClass public static void setUpClass() { } - + @AfterClass public static void tearDownClass() { } - + @Before public void setUp() { } - + @After public void tearDown() { } @@ -62,14 +57,14 @@ public void tearDown() { */ @Test public void testDiff() throws DiffException, PatchFailedException { - List orgList = Arrays.asList("A","B","C","A","B","B","A"); - List revList = Arrays.asList("C","B","A","B","A","C"); + List orgList = Arrays.asList("A", "B", "C", "A", "B", "B", "A"); + List revList = Arrays.asList("C", "B", "A", "B", "A", "C"); final Patch patch = Patch.generate(orgList, revList, new HistogramDiff().diff(orgList, revList)); System.out.println(patch); assertNotNull(patch); assertEquals(3, patch.getDeltas().size()); assertEquals("Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [DeleteDelta, position: 3, lines: [A, B]], [InsertDelta, position: 7, lines: [B, A, C]]]}", patch.toString()); - + List patched = patch.applyTo(orgList); assertEquals(revList, patched); } diff --git a/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java b/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java index 6ddb26de..93e2950e 100644 --- a/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java +++ b/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java @@ -15,61 +15,58 @@ */ package com.github.difflib.algorithm.jgit; -import com.github.difflib.algorithm.jgit.HistogramDiff; import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream; import com.github.difflib.TestConstants; import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.Patch; import com.github.difflib.patch.PatchFailedException; import java.io.IOException; -import java.util.Arrays; import java.util.List; import java.util.zip.ZipFile; import org.junit.After; import org.junit.AfterClass; +import static org.junit.Assert.*; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.*; /** * * @author toben */ public class LRHistogramDiffTest { - + public LRHistogramDiffTest() { } - + @BeforeClass public static void setUpClass() { } - + @AfterClass public static void tearDownClass() { } - + @Before public void setUp() { } - + @After public void tearDown() { } - @Test public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException, PatchFailedException { ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip"); List original = readStringListFromInputStream(zip.getInputStream(zip.getEntry("ta"))); List revised = readStringListFromInputStream(zip.getInputStream(zip.getEntry("tb"))); - + Patch patch = Patch.generate(original, revised, new HistogramDiff().diff(original, revised)); - + assertEquals(34, patch.getDeltas().size()); - + List created = patch.applyTo(original); assertArrayEquals(revised.toArray(), created.toArray()); } - + } diff --git a/src/test/java/com/github/difflib/algorithm/myers/MyersDiffTest.java b/src/test/java/com/github/difflib/algorithm/myers/MyersDiffTest.java index 6ef04e69..9b911ff1 100644 --- a/src/test/java/com/github/difflib/algorithm/myers/MyersDiffTest.java +++ b/src/test/java/com/github/difflib/algorithm/myers/MyersDiffTest.java @@ -15,18 +15,12 @@ */ package com.github.difflib.algorithm.myers; -import com.github.difflib.algorithm.myers.MyersDiff; -import com.github.difflib.DiffUtils; import com.github.difflib.algorithm.DiffException; import com.github.difflib.patch.Patch; import java.util.Arrays; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import static org.junit.Assert.*; +import org.junit.Test; /** * diff --git a/src/test/java/com/github/difflib/patch/PatchTest.java b/src/test/java/com/github/difflib/patch/PatchTest.java index cfda69ae..792785eb 100644 --- a/src/test/java/com/github/difflib/patch/PatchTest.java +++ b/src/test/java/com/github/difflib/patch/PatchTest.java @@ -1,7 +1,5 @@ package com.github.difflib.patch; -import com.github.difflib.patch.Patch; -import com.github.difflib.patch.PatchFailedException; import com.github.difflib.DiffUtils; import com.github.difflib.algorithm.DiffException; import java.util.Arrays; diff --git a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java index 616c189e..3326fe97 100644 --- a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java +++ b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java @@ -1,7 +1,5 @@ package com.github.difflib.text; -import com.github.difflib.text.DiffRow; -import com.github.difflib.text.DiffRowGenerator; import com.github.difflib.algorithm.DiffException; import java.util.Arrays; import java.util.List; @@ -24,7 +22,7 @@ public void testGenerator_Default() throws DiffException { assertEquals(3, rows.size()); } - + @Test public void testGenerator_Default2() throws DiffException { String first = "anything \n \nother"; @@ -83,14 +81,14 @@ private void print(List diffRows) { System.out.println(row); } } - + @Test public void testGeneratorWithWordWrap() throws DiffException { String first = "anything \n \nother"; String second = "anything\n\nother"; DiffRowGenerator generator = DiffRowGenerator.create() - .columnWidth(5) + .columnWidth(5) .build(); List rows = generator.generateDiffRows(split(first), split(second)); print(rows); @@ -100,7 +98,7 @@ public void testGeneratorWithWordWrap() throws DiffException { assertEquals("[CHANGE, ,]", rows.get(1).toString()); assertEquals("[EQUAL,other,other]", rows.get(2).toString()); } - + @Test public void testGeneratorWithMerge() throws DiffException { String first = "anything \n \nother"; @@ -118,20 +116,20 @@ public void testGeneratorWithMerge() throws DiffException { assertEquals("[CHANGE, ,]", rows.get(1).toString()); assertEquals("[EQUAL,other,other]", rows.get(2).toString()); } - + @Test public void testGeneratorWithMerge2() throws DiffException { DiffRowGenerator generator = DiffRowGenerator.create() .showInlineDiffs(true) .mergeOriginalRevised(true) .build(); - List rows = generator.generateDiffRows(Arrays.asList("Test"),Arrays.asList("ester")); + List rows = generator.generateDiffRows(Arrays.asList("Test"), Arrays.asList("ester")); print(rows); assertEquals(1, rows.size()); assertEquals("[CHANGE,Tester,ester]", rows.get(0).toString()); } - + @Test public void testGeneratorWithMerge3() throws DiffException { String first = "test\nanything \n \nother"; @@ -152,7 +150,7 @@ public void testGeneratorWithMerge3() throws DiffException { assertEquals("[INSERT,test,test]", rows.get(4).toString()); assertEquals("[INSERT,test2,test2]", rows.get(5).toString()); } - + @Test public void testGeneratorWithMergeByWord4() throws DiffException { DiffRowGenerator generator = DiffRowGenerator.create() @@ -160,13 +158,13 @@ public void testGeneratorWithMergeByWord4() throws DiffException { .mergeOriginalRevised(true) .inlineDiffByWord(true) .build(); - List rows = generator.generateDiffRows(Arrays.asList("Test"),Arrays.asList("ester")); + List rows = generator.generateDiffRows(Arrays.asList("Test"), Arrays.asList("ester")); print(rows); assertEquals(1, rows.size()); assertEquals("[CHANGE,Testester,ester]", rows.get(0).toString()); } - + @Test public void testGeneratorWithMergeByWord5() throws DiffException { DiffRowGenerator generator = DiffRowGenerator.create() @@ -175,20 +173,20 @@ public void testGeneratorWithMergeByWord5() throws DiffException { .inlineDiffByWord(true) .columnWidth(80) .build(); - List rows = generator.generateDiffRows(Arrays.asList("Test feature"),Arrays.asList("ester feature best")); + List rows = generator.generateDiffRows(Arrays.asList("Test feature"), Arrays.asList("ester feature best")); print(rows); assertEquals(1, rows.size()); assertEquals("[CHANGE,Testester
feature best,ester feature best]", rows.get(0).toString()); } - + @Test public void testSplitString() { List list = DiffRowGenerator.splitStringPreserveDelimiter("test,test2"); assertEquals(3, list.size()); assertEquals("[test, ,, test2]", list.toString()); } - + @Test public void testSplitString2() { List list = DiffRowGenerator.splitStringPreserveDelimiter("test , test2"); @@ -196,7 +194,7 @@ public void testSplitString2() { assertEquals(5, list.size()); assertEquals("[test, , ,, , test2]", list.toString()); } - + @Test public void testSplitString3() { List list = DiffRowGenerator.splitStringPreserveDelimiter("test,test2,"); @@ -204,8 +202,7 @@ public void testSplitString3() { assertEquals(4, list.size()); assertEquals("[test, ,, test2, ,]", list.toString()); } - - + @Test public void testGeneratorExample1() throws DiffException { DiffRowGenerator generator = DiffRowGenerator.create() @@ -218,13 +215,13 @@ public void testGeneratorExample1() throws DiffException { List rows = generator.generateDiffRows( Arrays.asList("This is a test senctence."), Arrays.asList("This is a test for diffutils.")); - - System.out.println(rows.get(0).getOldLine()); - + + System.out.println(rows.get(0).getOldLine()); + assertEquals(1, rows.size()); assertEquals("This is a test ~senctence~**for diffutils**.", rows.get(0).getOldLine()); } - + @Test public void testGeneratorExample2() throws DiffException { DiffRowGenerator generator = DiffRowGenerator.create() @@ -236,25 +233,25 @@ public void testGeneratorExample2() throws DiffException { List rows = generator.generateDiffRows( Arrays.asList("This is a test senctence.", "This is the second line.", "And here is the finish."), Arrays.asList("This is a test for diffutils.", "This is the second line.")); - + System.out.println("|original|new|"); System.out.println("|--------|---|"); for (DiffRow row : rows) { System.out.println("|" + row.getOldLine() + "|" + row.getNewLine() + "|"); } - + assertEquals(3, rows.size()); assertEquals("This is a test ~senctence~.", rows.get(0).getOldLine()); assertEquals("This is a test **for diffutils**.", rows.get(0).getNewLine()); } - + @Test public void testGeneratorUnchanged() throws DiffException { String first = "anything \n \nother"; String second = "anything\n\nother"; DiffRowGenerator generator = DiffRowGenerator.create() - .columnWidth(5) + .columnWidth(5) .reportLinesUnchanged(true) .build(); List rows = generator.generateDiffRows(split(first), split(second)); diff --git a/src/test/java/com/github/difflib/text/StringUtilsTest.java b/src/test/java/com/github/difflib/text/StringUtilsTest.java index ad8f1db2..2b120d09 100644 --- a/src/test/java/com/github/difflib/text/StringUtilsTest.java +++ b/src/test/java/com/github/difflib/text/StringUtilsTest.java @@ -16,8 +16,8 @@ package com.github.difflib.text; import java.util.Collections; -import org.junit.Test; import static org.junit.Assert.*; +import org.junit.Test; /** * @@ -38,7 +38,7 @@ public void testHtmlEntites() { */ @Test public void testNormalize_String() { - assertEquals(" test",StringUtils.normalize("\ttest")); + assertEquals(" test", StringUtils.normalize("\ttest")); } /** @@ -46,7 +46,7 @@ public void testNormalize_String() { */ @Test public void testNormalize_List() { - assertEquals(Collections.singletonList(" test"),StringUtils.normalize(Collections.singletonList("\ttest"))); + assertEquals(Collections.singletonList(" test"), StringUtils.normalize(Collections.singletonList("\ttest"))); } /** @@ -58,10 +58,10 @@ public void testWrapText_String_int() { assertEquals("tes
t", StringUtils.wrapText("test", 3)); assertEquals("test", StringUtils.wrapText("test", 10)); } - + @Test(expected = IllegalArgumentException.class) public void testWrapText_String_int_zero() { assertEquals("test", StringUtils.wrapText("test", -1)); } - + } From 90eaf2e134287459e3bd88df261fb64c2146d966 Mon Sep 17 00:00:00 2001 From: wumpz Date: Wed, 8 Nov 2017 08:29:59 +0100 Subject: [PATCH 07/16] starting corrections for maven central release --- pom.xml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index c15a9a96..4c64725e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,24 +4,27 @@ diffutils jar 2.1-SNAPSHOT - java-diff-utils The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. https://github.com/wumpz/java-diff-utils 2009 - + + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + scm:git:https://github.com/wumpz/java-diff-utils.git scm:git:ssh://git@github.com:wumpz/java-diff-utils.git https://github.com/wumpz/java-diff-utils.git - diffutils-2.0 + HEAD From d2a432059d3c401e01318aa9780dc2041ce1ab36 Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 12:30:47 +0100 Subject: [PATCH 08/16] preparing maven central release --- README.md | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca9f2979..28d5ff58 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ But it can easily replaced by any other which is better for handing your texts. ### Changelog ### * Version 2.1-SNAPSHOT * included checkstyle source code conventions + * groupid changed to **com.github.wumpz**, due to maven central releasing * Version 2.0 * switch to maven and removed other artifacts * changed groupid to **com.github.java-diff-utils** due to different forks at github diff --git a/pom.xml b/pom.xml index 4c64725e..826d9c91 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.github.java-diff-utils + com.github.wumpz diffutils jar 2.1-SNAPSHOT From 573460df9c4c0a9a034cbf9ffdd2213000c5a7cd Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 12:33:27 +0100 Subject: [PATCH 09/16] preparing maven central release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28d5ff58..a413cf0d 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ This is a valid piece of source code: Just add the code below to your maven dependencies: ``` - com.github.java-diff-utils + com.github.wumpz diffutils    2.0-SNAPSHOT From 4f6f8dbcf2ad2091aa6f1f5190cea06476c59486 Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 14:34:50 +0100 Subject: [PATCH 10/16] fixes #14 --- README.md | 1 + .../github/difflib/text/DiffRowGenerator.java | 55 ++++++++++++------- .../difflib/text/DiffRowGeneratorTest.java | 26 ++++++++- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index a413cf0d..be31df25 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ But it can easily replaced by any other which is better for handing your texts. * Version 2.1-SNAPSHOT * included checkstyle source code conventions * groupid changed to **com.github.wumpz**, due to maven central releasing + * allow configurable splitting of lines to define the blocks to compare (words, characters, phrases). * Version 2.0 * switch to maven and removed other artifacts * changed groupid to **com.github.java-diff-utils** due to different forks at github diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java index ad13542b..9df68481 100644 --- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java +++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java @@ -47,16 +47,34 @@ * */ public class DiffRowGenerator { - + public static final Pattern SPLIT_BY_WORD_PATTERN = Pattern.compile("\\s+|[,.\\[\\](){}/\\\\*+\\-#]"); + public static final BiPredicate IGNORE_WHITESPACE_EQUALIZER = (original, revised) -> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " ")); + public static final BiPredicate DEFAULT_EQUALIZER = Object::equals; - private static final Pattern SPLIT_PATTERN = Pattern.compile("\\s+|[,.\\[\\](){}/\\\\*+\\-#]"); + + /** + * Splitting lines by word to achieve word by word diff checking. + */ + public static final Function> SPLITTER_BY_WORD = line -> splitStringPreserveDelimiter(line, SPLIT_BY_WORD_PATTERN); + + /** + * Splitting lines by character to achieve char by char diff checking. + */ + public static final Function> SPLITTER_BY_CHARACTER = line -> { + List list = new ArrayList<>(line.length()); + for (Character character : line.toCharArray()) { + list.add(character.toString()); + } + return list; + }; + private final boolean showInlineDiffs; private final boolean ignoreWhiteSpaces; private final Function oldTag; private final Function newTag; - private final boolean inlineDiffByWord; + private final Function> inlineDiffSplitter; private final int columnWidth; private final BiPredicate equalizer; private final boolean mergeOriginalRevised; @@ -78,8 +96,8 @@ public static class Builder { private int columnWidth = 0; private boolean mergeOriginalRevised = false; - private boolean inlineDiffByWord = false; private boolean reportLinesUnchanged = false; + private Function> inlineDiffSplitter = SPLITTER_BY_CHARACTER; private Builder() { } @@ -177,7 +195,13 @@ public Builder mergeOriginalRevised(boolean mergeOriginalRevised) { * deliver no in word changes. */ public Builder inlineDiffByWord(boolean inlineDiffByWord) { - this.inlineDiffByWord = inlineDiffByWord; + inlineDiffSplitter = inlineDiffByWord?SPLITTER_BY_WORD:SPLITTER_BY_CHARACTER; + return this; + } + + + public Builder inlineDiffBySplitter(Function> inlineDiffSplitter) { + this.inlineDiffSplitter = inlineDiffSplitter; return this; } } @@ -193,9 +217,11 @@ private DiffRowGenerator(Builder builder) { newTag = builder.newTag; columnWidth = builder.columnWidth; mergeOriginalRevised = builder.mergeOriginalRevised; - inlineDiffByWord = builder.inlineDiffByWord; + inlineDiffSplitter = builder.inlineDiffSplitter; equalizer = ignoreWhiteSpaces ? IGNORE_WHITESPACE_EQUALIZER : DEFAULT_EQUALIZER; reportLinesUnchanged = builder.reportLinesUnchanged; + + Objects.requireNonNull(inlineDiffSplitter); } /** @@ -318,19 +344,8 @@ private List generateInlineDiffs(Delta delta) throws DiffExcept String joinedOrig = String.join("\n", orig); String joinedRev = String.join("\n", rev); - if (inlineDiffByWord) { - origList = splitStringPreserveDelimiter(joinedOrig); - revList = splitStringPreserveDelimiter(joinedRev); - } else { - origList = new ArrayList<>(joinedOrig.length()); - revList = new ArrayList<>(joinedRev.length()); - for (Character character : joinedOrig.toCharArray()) { - origList.add(character.toString()); - } - for (Character character : joinedRev.toCharArray()) { - revList.add(character.toString()); - } - } + origList = inlineDiffSplitter.apply(joinedOrig); + revList = inlineDiffSplitter.apply(joinedRev); List> inlineDeltas = DiffUtils.diff(origList, revList).getDeltas(); @@ -404,7 +419,7 @@ public static void wrapInTag(List sequence, int startPosition, sequence.add(endPosition, generator.apply(false)); } - protected final static List splitStringPreserveDelimiter(String str) { + protected final static List splitStringPreserveDelimiter(String str, Pattern SPLIT_PATTERN) { List list = new ArrayList<>(); if (str != null) { Matcher matcher = SPLIT_PATTERN.matcher(str); diff --git a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java index 3326fe97..19748282 100644 --- a/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java +++ b/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java @@ -3,6 +3,7 @@ import com.github.difflib.algorithm.DiffException; import java.util.Arrays; import java.util.List; +import java.util.regex.Pattern; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -182,14 +183,14 @@ public void testGeneratorWithMergeByWord5() throws DiffException { @Test public void testSplitString() { - List list = DiffRowGenerator.splitStringPreserveDelimiter("test,test2"); + List list = DiffRowGenerator.splitStringPreserveDelimiter("test,test2", DiffRowGenerator.SPLIT_BY_WORD_PATTERN); assertEquals(3, list.size()); assertEquals("[test, ,, test2]", list.toString()); } @Test public void testSplitString2() { - List list = DiffRowGenerator.splitStringPreserveDelimiter("test , test2"); + List list = DiffRowGenerator.splitStringPreserveDelimiter("test , test2", DiffRowGenerator.SPLIT_BY_WORD_PATTERN); System.out.println(list); assertEquals(5, list.size()); assertEquals("[test, , ,, , test2]", list.toString()); @@ -197,7 +198,7 @@ public void testSplitString2() { @Test public void testSplitString3() { - List list = DiffRowGenerator.splitStringPreserveDelimiter("test,test2,"); + List list = DiffRowGenerator.splitStringPreserveDelimiter("test,test2,", DiffRowGenerator.SPLIT_BY_WORD_PATTERN); System.out.println(list); assertEquals(4, list.size()); assertEquals("[test, ,, test2, ,]", list.toString()); @@ -262,4 +263,23 @@ public void testGeneratorUnchanged() throws DiffException { assertEquals("[CHANGE, ,]", rows.get(1).toString()); assertEquals("[EQUAL,other,other]", rows.get(2).toString()); } + + @Test + public void testGeneratorIssue14() throws DiffException { + DiffRowGenerator generator = DiffRowGenerator.create() + .showInlineDiffs(true) + .mergeOriginalRevised(true) + .inlineDiffBySplitter(line -> DiffRowGenerator.splitStringPreserveDelimiter(line, Pattern.compile(","))) + .oldTag(f -> "~") + .newTag(f -> "**") + .build(); + List rows = generator.generateDiffRows( + Arrays.asList("J. G. Feldstein, Chair"), + Arrays.asList("T. P. Pastor, Chair")); + + System.out.println(rows.get(0).getOldLine()); + + assertEquals(1, rows.size()); + assertEquals("~J. G. Feldstein~**T. P. Pastor**, Chair", rows.get(0).getOldLine()); + } } From 5764356be216399995e05887b1b8f4d6b1921de6 Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 22:12:57 +0100 Subject: [PATCH 11/16] --- nbactions.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 nbactions.xml diff --git a/nbactions.xml b/nbactions.xml new file mode 100644 index 00000000..055d78be --- /dev/null +++ b/nbactions.xml @@ -0,0 +1,11 @@ + + + + CUSTOM-clean deploy + clean deploy + + clean + deploy + + + From 4f6b1839f8b8490ac81f255b0b3ab3f40382c543 Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 22:24:46 +0100 Subject: [PATCH 12/16] --- pom.xml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pom.xml b/pom.xml index 826d9c91..5c415827 100644 --- a/pom.xml +++ b/pom.xml @@ -245,6 +245,36 @@ + + sign-release-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + sign-artifacts + verify + + sign + + + f22e0543 + + + + + + + doclint-java8-disable From 0a2053f71ad128246f74e260444d7a8187efa02b Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 22:38:40 +0100 Subject: [PATCH 13/16] [maven-release-plugin] prepare release diffutils-2.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5c415827..e24677a9 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.wumpz diffutils jar - 2.1-SNAPSHOT + 2.1 java-diff-utils The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. https://github.com/wumpz/java-diff-utils @@ -24,7 +24,7 @@ scm:git:https://github.com/wumpz/java-diff-utils.git scm:git:ssh://git@github.com:wumpz/java-diff-utils.git https://github.com/wumpz/java-diff-utils.git - HEAD + diffutils-2.1 From 15af24ac021fc5967d711b36525ae0fea16e28e6 Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 22:38:40 +0100 Subject: [PATCH 14/16] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e24677a9..1494f0e9 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.wumpz diffutils jar - 2.1 + 2.2-SNAPSHOT java-diff-utils The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. https://github.com/wumpz/java-diff-utils @@ -24,7 +24,7 @@ scm:git:https://github.com/wumpz/java-diff-utils.git scm:git:ssh://git@github.com:wumpz/java-diff-utils.git https://github.com/wumpz/java-diff-utils.git - diffutils-2.1 + HEAD From 424cfcefd7da271cc7fc7b716460ff47256d06aa Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 22:45:47 +0100 Subject: [PATCH 15/16] --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1494f0e9..710b60f1 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,6 @@ true false forked-path - install From 244e7e7fd89f313cc74788a79e6f9e4ff4eea93c Mon Sep 17 00:00:00 2001 From: wumpz Date: Thu, 9 Nov 2017 22:47:30 +0100 Subject: [PATCH 16/16] [maven-release-plugin] prepare release diffutils-2.2 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 710b60f1..87d136e0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.wumpz diffutils jar - 2.2-SNAPSHOT + 2.2 java-diff-utils The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java. https://github.com/wumpz/java-diff-utils @@ -24,7 +24,7 @@ scm:git:https://github.com/wumpz/java-diff-utils.git scm:git:ssh://git@github.com:wumpz/java-diff-utils.git https://github.com/wumpz/java-diff-utils.git - HEAD + diffutils-2.2