GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix for #141 (#144) · angang1989/java-diff-utils@ea9942d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java-diff-utils/src
    • main/java/com/github/difflib/unifieddiff
      • UnifiedDiffReader.java
    • test
      • java/com/github/difflib/unifieddiff
        • UnifiedDiffReaderTest.java
      • resources/com/github/difflib/unifieddiff
        • problem_diff_issue141.diff
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ private String extractFileName(String _line) {
353353
line = line.substring(0, matcher.start());
354354
}
355355
line = line.split("\t")[0];
356-
return line.substring(4).replaceFirst("^(a|b|old|new)(\\/)?", "")
356+
return line.substring(4).replaceFirst("^(a|b|old|new)/", "")
357357
.trim();
358358
}
359359

Collapse file

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

Copy file name to clipboardExpand all lines: java-diff-utils/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testParseIssue46() throws IOException {
122122
assertThat(diff.getFiles().size()).isEqualTo(1);
123123

124124
UnifiedDiffFile file1 = diff.getFiles().get(0);
125-
assertThat(file1.getFromFile()).isEqualTo(".vhd");
125+
assertThat(file1.getFromFile()).isEqualTo("a.vhd");
126126
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(1);
127127

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

385385
assertThat(diff.getFiles()).extracting(f -> f.getFromFile()).contains("src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java");
386386
}
387+
388+
@Test
389+
public void testParseIssue141() throws IOException {
390+
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(
391+
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue141.diff"));
392+
UnifiedDiffFile file1 = diff.getFiles().get(0);
393+
394+
assertThat(file1.getFromFile()).isEqualTo("a.txt");
395+
assertThat(file1.getToFile()).isEqualTo("a1.txt");
396+
}
387397
}
Collapse file

‎java-diff-utils/src/test/resources/com/github/difflib/unifieddiff/problem_diff_issue141.diff‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a.txt
2+
+++ a1.txt
3+
@@ -8,7 +8,7 @@
4+
<Setting>
5+
<Setting a>
6+
<setting b>
7+
- <value>23</value>
8+
+ <value>24</value>
9+
</setting b>
10+
<setting c>
11+
<value>1</value>

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.