mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
Compare commits
9 Commits
java-diff-
...
java-diff-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49b20133c2 | ||
|
|
84662956a0 | ||
|
|
f1b81c621b | ||
|
|
ededee0596 | ||
|
|
3b45d8f37d | ||
|
|
eada27b370 | ||
|
|
1d98467cc3 | ||
|
|
6c58e219b0 | ||
|
|
53c9ca3478 |
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: https://paypal.me/wumpz
|
||||
@@ -7,8 +7,12 @@ This project uses a custom versioning scheme (and not [Semantic Versioning](http
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [4.4] – 2019-11-06
|
||||
|
||||
### Changed
|
||||
|
||||
* java-diff-utils is now a multi module project. The main project java-diff-utils now comes without any dependencies.
|
||||
* started reimplementation of unified diff tools
|
||||
* Exchange `0 += 1` for `0 = 1` in UnifiedDiffUtils
|
||||
* preview of new Unified Diff Reader / Writer. This is not yet feature complete but passes the tests of the old version.
|
||||
* feel free to issue some change requests for the api.
|
||||
|
||||
@@ -80,7 +80,7 @@ Just add the code below to your maven dependencies:
|
||||
<dependency>
|
||||
<groupId>io.github.java-diff-utils</groupId>
|
||||
<artifactId>java-diff-utils</artifactId>
|
||||
<version>4.0</version>
|
||||
<version>4.4</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -88,5 +88,5 @@ or using gradle:
|
||||
|
||||
```groovy
|
||||
// https://mvnrepository.com/artifact/io.github.java-diff-utils/java-diff-utils
|
||||
implementation "io.github.java-diff-utils:java-diff-utils:4.0"
|
||||
implementation "io.github.java-diff-utils:java-diff-utils:4.4"
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.java-diff-utils</groupId>
|
||||
<artifactId>java-diff-utils-parent</artifactId>
|
||||
<version>4.4</version>
|
||||
<version>4.5</version>
|
||||
</parent>
|
||||
<artifactId>java-diff-utils-jgit</artifactId>
|
||||
<name>java-diff-utils-jgit</name>
|
||||
|
||||
@@ -13,7 +13,6 @@ You can copy and paste the single properties, into the pom.xml file and the IDE
|
||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
||||
-->
|
||||
<netbeans.compile.on.save>none</netbeans.compile.on.save>
|
||||
<netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>io.github.java-diff-utils</groupId>
|
||||
<artifactId>java-diff-utils-parent</artifactId>
|
||||
<version>4.4</version>
|
||||
<version>4.5</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -49,7 +49,7 @@
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
<manifestEntries>
|
||||
<!-- identical to OSGI name -->
|
||||
<Automatic-Module-Name>io.github.java-diff-utils</Automatic-Module-Name>
|
||||
<Automatic-Module-Name>io.github.javadiffutils</Automatic-Module-Name>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
|
||||
@@ -97,7 +97,9 @@ public final class UnifiedDiffReader {
|
||||
if (processLine(line, LINE_NORMAL, LINE_ADD, LINE_DEL) == false) {
|
||||
throw new UnifiedDiffParserException("expected data line not found");
|
||||
}
|
||||
if (originalTxt.size() == old_size && revisedTxt.size() == new_size) {
|
||||
if ((originalTxt.size() == old_size && revisedTxt.size() == new_size)
|
||||
|| (old_size==0 && new_size==0 && originalTxt.size() == this.old_ln
|
||||
&& revisedTxt.size() == this.new_ln)) {
|
||||
finalizeChunk();
|
||||
break;
|
||||
}
|
||||
@@ -241,9 +243,9 @@ public final class UnifiedDiffReader {
|
||||
Matcher matcher = TIMESTAMP_REGEXP.matcher(_line);
|
||||
String line = _line;
|
||||
if (matcher.find()) {
|
||||
line = line.substring(1, matcher.start());
|
||||
line = line.substring(0, matcher.start());
|
||||
}
|
||||
return line.substring(4).replaceFirst("^(a|b)\\/", "")
|
||||
return line.substring(4).replaceFirst("^(a|b|old|new)(\\/)?", "")
|
||||
.replace(TIMESTAMP_REGEXP.toString(), "").trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -141,4 +141,20 @@ public class UnifiedDiffReaderTest {
|
||||
assertThat(diff.getTail()).isNull();
|
||||
assertThat(diff.getHeader()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseIssue51() throws IOException {
|
||||
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(
|
||||
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue51.diff"));
|
||||
|
||||
System.out.println(diff);
|
||||
|
||||
assertThat(diff.getFiles().size()).isEqualTo(2);
|
||||
|
||||
UnifiedDiffFile file1 = diff.getFiles().get(0);
|
||||
assertThat(file1.getFromFile()).isEqualTo("f1");
|
||||
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(1);
|
||||
|
||||
assertThat(diff.getTail()).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
diff -U0 old/f1 new/f1
|
||||
--- old/f1 2019-09-25 14:38:06.000000000 +0200
|
||||
+++ new/f1 2019-09-25 14:38:27.000000000 +0200
|
||||
@@ -1 +1 @@
|
||||
-a\nb
|
||||
+a\nb\nd
|
||||
diff -U0 old/f2 new/f2
|
||||
--- old/f2 2019-09-25 14:38:14.000000000 +0200
|
||||
+++ new/f2 2019-09-25 14:38:32.000000000 +0200
|
||||
@@ -1 +1 @@
|
||||
-a\nc
|
||||
4
pom.xml
4
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.java-diff-utils</groupId>
|
||||
<artifactId>java-diff-utils-parent</artifactId>
|
||||
<version>4.4</version>
|
||||
<version>4.5</version>
|
||||
<name>java-diff-utils-parent</name>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
@@ -29,7 +29,7 @@
|
||||
<connection>scm:git:https://github.com/java-diff-utils/java-diff-utils.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com:java-diff-utils/java-diff-utils.git</developerConnection>
|
||||
<url>https://github.com/java-diff-utils/java-diff-utils.git</url>
|
||||
<tag>java-diff-utils-parent-4.4</tag>
|
||||
<tag>java-diff-utils-parent-4.5</tag>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
|
||||
Reference in New Issue
Block a user