Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private String extractFileName(String _line) {
line = line.substring(0, matcher.start());
}
line = line.split("\t")[0];
return line.substring(4).replaceFirst("^(a|b|old|new)(\\/)?", "")
return line.substring(4).replaceFirst("^(a|b|old|new)/", "")
.trim();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void testParseIssue46() throws IOException {
assertThat(diff.getFiles().size()).isEqualTo(1);

UnifiedDiffFile file1 = diff.getFiles().get(0);
assertThat(file1.getFromFile()).isEqualTo(".vhd");
assertThat(file1.getFromFile()).isEqualTo("a.vhd");
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(1);

assertThat(diff.getTail()).isNull();
Expand Down Expand Up @@ -384,4 +384,14 @@ public void testParseIssue123() throws IOException {

assertThat(diff.getFiles()).extracting(f -> f.getFromFile()).contains("src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java");
}

@Test
public void testParseIssue141() throws IOException {
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue141.diff"));
UnifiedDiffFile file1 = diff.getFiles().get(0);

assertThat(file1.getFromFile()).isEqualTo("a.txt");
assertThat(file1.getToFile()).isEqualTo("a1.txt");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a.txt
+++ a1.txt
@@ -8,7 +8,7 @@
<Setting>
<Setting a>
<setting b>
- <value>23</value>
+ <value>24</value>
</setting b>
<setting c>
<value>1</value>