Skip to content

Commit 7620f91

Browse files
committed
fixes #80
1 parent a8e4ce2 commit 7620f91

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

java-diff-utils/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@
5151
</archive>
5252
</configuration>
5353
</plugin>
54+
<plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-surefire-plugin</artifactId>
57+
<configuration>
58+
<systemPropertyVariables>
59+
<java.util.logging.config.file>target/test-classes/logging.properties</java.util.logging.config.file>
60+
</systemPropertyVariables>
61+
</configuration>
62+
</plugin>
5463
</plugins>
5564
</build>
5665
</project>

java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ public final class UnifiedDiffReader {
6666
// [/^-/, del], [/^\+/, add], [/^\\ No newline at end of file$/, eof]];
6767
private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
6868
String headerTxt = "";
69-
LOG.log(Level.INFO, "header parsing");
69+
LOG.log(Level.FINE, "header parsing");
7070
String line = null;
7171
while (READER.ready()) {
7272
line = READER.readLine();
73-
LOG.log(Level.INFO, "parsing line {0}", line);
73+
LOG.log(Level.FINE, "parsing line {0}", line);
7474
if (DIFF_COMMAND.validLine(line) || INDEX.validLine(line)
7575
|| FROM_FILE.validLine(line) || TO_FILE.validLine(line)) {
7676
break;
@@ -139,11 +139,11 @@ public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOExceptio
139139
private boolean processLine(String line, UnifiedDiffLine... rules) throws UnifiedDiffParserException {
140140
for (UnifiedDiffLine rule : rules) {
141141
if (rule.processLine(line)) {
142-
LOG.info(" >>> processed rule " + rule.toString());
142+
LOG.fine(" >>> processed rule " + rule.toString());
143143
return true;
144144
}
145145
}
146-
LOG.info(" >>> no rule matched " + line);
146+
LOG.warning(" >>> no rule matched " + line);
147147
return false;
148148
//throw new UnifiedDiffParserException("parsing error at line " + line);
149149
}
@@ -161,7 +161,7 @@ private void initFileIfNecessary() {
161161

162162
private void processDiff(MatchResult match, String line) {
163163
//initFileIfNecessary();
164-
LOG.log(Level.INFO, "start {0}", line);
164+
LOG.log(Level.FINE, "start {0}", line);
165165
String[] fromTo = parseFileNames(READER.lastLine());
166166
actualFile.setFromFile(fromTo[0]);
167167
actualFile.setToFile(fromTo[1]);
@@ -223,7 +223,7 @@ private static Integer toInteger(MatchResult match, int group, int defValue) thr
223223

224224
private void processIndex(MatchResult match, String line) {
225225
//initFileIfNecessary();
226-
LOG.log(Level.INFO, "index {0}", line);
226+
LOG.log(Level.FINE, "index {0}", line);
227227
actualFile.setIndex(line.substring(6));
228228
}
229229

java-diff-utils/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,19 @@ public void testParseIssue51() throws IOException {
157157

158158
assertThat(diff.getTail()).isNull();
159159
}
160+
161+
@Test
162+
public void testParseIssue79() throws IOException {
163+
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(
164+
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue79.diff"));
165+
166+
assertThat(diff.getFiles().size()).isEqualTo(1);
167+
168+
UnifiedDiffFile file1 = diff.getFiles().get(0);
169+
assertThat(file1.getFromFile()).isEqualTo("Main.java");
170+
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(1);
171+
172+
assertThat(diff.getTail()).isNull();
173+
assertThat(diff.getHeader()).isNull();
174+
}
160175
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
diff --git a/test/Issue.java b/test/Issue.java
2+
new file mode 100644
3+
index 00000000..9702606e
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
handlers=java.util.logging.ConsoleHandler
2+
3+
.level=INFO
4+
com.github.difflib.unifieddiff.level=FINE
5+
6+
java.util.logging.ConsoleHandler.level=INFO
7+
#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
8+

0 commit comments

Comments
 (0)