This commit is contained in:
Tobias Warneke
2019-08-14 23:38:12 +02:00
parent 5cc9625275
commit a40c396678
3 changed files with 24 additions and 1 deletions

View File

@@ -46,7 +46,7 @@ public final class UnifiedDiffReader {
new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", this::processIndex),
new UnifiedDiffLine(true, "^---\\s", this::processFromFile),
new UnifiedDiffLine(true, "^\\+\\+\\+\\s", this::processToFile),
new UnifiedDiffLine(false, UNIFIED_DIFF_CHUNK_REGEXP, this::processChunk),
new UnifiedDiffLine(true, UNIFIED_DIFF_CHUNK_REGEXP, this::processChunk),
new UnifiedDiffLine("^\\s+", this::processNormalLine),
new UnifiedDiffLine("^-", this::processDelLine),
new UnifiedDiffLine("^+", this::processAddLine)

View File

@@ -111,4 +111,19 @@ public class UnifiedDiffReaderTest {
assertTrue(m.find());
}
@Test
public void testParseIssue46() throws IOException {
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue46.diff"));
--- comment
System.out.println(diff);
assertThat(diff.getFiles().size()).isEqualTo(1);
UnifiedDiffFile file1 = diff.getFiles().get(0);
assertThat(file1.getFromFile()).isEqualTo("src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt");
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(3);
assertThat(diff.getTail()).isEqualTo("2.17.1.windows.2\n\n");
}
}

View File

@@ -0,0 +1,8 @@
--- a.vhd 2019-04-18 13:49:39.516149751 +0200
+++ b.vhd 2019-04-18 11:33:08.372563078 +0200
@@ -2819,3 +2819,3 @@
--- some comment
-bla
-bla
+
+