Skip to content

Commit ea252bf

Browse files
committed
fix: JGitDiff bug with "no newline" lines in diff
1 parent 8d8b14b commit ea252bf

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • src/main/java/org/variantsync/diffdetective/variation/diff/construction

src/main/java/org/variantsync/diffdetective/variation/diff/construction/JGitDiff.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
import java.io.IOException;
1717
import java.io.StringReader;
1818
import java.nio.charset.StandardCharsets;
19+
import java.util.regex.Pattern;
1920

2021
/**
2122
* Class which groups functions of parsing variation diffs with JGit.
2223
* @author Paul Bittner
2324
*/
2425
public final class JGitDiff {
26+
private final static Pattern NO_NEWLINE_AT_END_OF_FILE = Pattern.compile("\n\\\\ No newline at end of file");
27+
2528
private JGitDiff() {}
2629

2730
/**
@@ -90,7 +93,8 @@ Using our own formatter without diff headers (paired with a maximum context (?))
9093
new BufferedReader(new StringReader(textDiff))
9194
);
9295

93-
//textDiff = textDiff.replace("\\ No newline at end of file\n", "");
96+
97+
textDiff = NO_NEWLINE_AT_END_OF_FILE.matcher(textDiff).replaceAll("");
9498
//textDiff = HUNK_HEADER_REGEX.matcher(textDiff).replaceAll("");
9599

96100
final VariationDiff<DiffLinesLabel> d;

0 commit comments

Comments
 (0)