9 Commits

Author SHA1 Message Date
Tobias Warneke
49b20133c2 [maven-release-plugin] prepare release java-diff-utils-parent-4.5 2019-11-17 22:07:31 +01:00
Tobias Warneke
84662956a0 2019-11-17 22:04:38 +01:00
Tobias Warneke
f1b81c621b Merge origin/master 2019-11-13 23:17:28 +01:00
Tobias Warneke
ededee0596 fixes #51 2019-11-13 23:16:38 +01:00
Tobias
3b45d8f37d Update CHANGELOG.md 2019-11-10 21:17:42 +01:00
Tobias Warneke
eada27b370 Merge multi-module 2019-11-10 21:07:10 +01:00
Tobias
1d98467cc3 Update README.md 2019-11-08 08:56:42 +01:00
Tobias Warneke
6c58e219b0 [maven-release-plugin] prepare for next development iteration 2019-11-06 22:58:42 +01:00
Tobias
53c9ca3478 Create FUNDING.yml 2019-11-05 16:02:48 +01:00
10 changed files with 55 additions and 11 deletions

12
.github/FUNDING.yml vendored Normal file
View 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

View File

@@ -7,8 +7,12 @@ This project uses a custom versioning scheme (and not [Semantic Versioning](http
## [Unreleased] ## [Unreleased]
## [4.4] 2019-11-06
### Changed ### 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 * 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. * 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. * feel free to issue some change requests for the api.

View File

@@ -80,7 +80,7 @@ Just add the code below to your maven dependencies:
<dependency> <dependency>
<groupId>io.github.java-diff-utils</groupId> <groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils</artifactId> <artifactId>java-diff-utils</artifactId>
<version>4.0</version> <version>4.4</version>
</dependency> </dependency>
``` ```
@@ -88,5 +88,5 @@ or using gradle:
```groovy ```groovy
// https://mvnrepository.com/artifact/io.github.java-diff-utils/java-diff-utils // 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"
``` ```

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>io.github.java-diff-utils</groupId> <groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId> <artifactId>java-diff-utils-parent</artifactId>
<version>4.4</version> <version>4.5</version>
</parent> </parent>
<artifactId>java-diff-utils-jgit</artifactId> <artifactId>java-diff-utils-jgit</artifactId>
<name>java-diff-utils-jgit</name> <name>java-diff-utils-jgit</name>

View File

@@ -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). 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. 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> <netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
</properties> </properties>
</project-shared-configuration> </project-shared-configuration>

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>io.github.java-diff-utils</groupId> <groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId> <artifactId>java-diff-utils-parent</artifactId>
<version>4.4</version> <version>4.5</version>
</parent> </parent>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -49,7 +49,7 @@
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries> <manifestEntries>
<!-- identical to OSGI name --> <!-- 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> </manifestEntries>
</archive> </archive>
</configuration> </configuration>

View File

@@ -97,7 +97,9 @@ public final class UnifiedDiffReader {
if (processLine(line, LINE_NORMAL, LINE_ADD, LINE_DEL) == false) { if (processLine(line, LINE_NORMAL, LINE_ADD, LINE_DEL) == false) {
throw new UnifiedDiffParserException("expected data line not found"); 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(); finalizeChunk();
break; break;
} }
@@ -241,9 +243,9 @@ public final class UnifiedDiffReader {
Matcher matcher = TIMESTAMP_REGEXP.matcher(_line); Matcher matcher = TIMESTAMP_REGEXP.matcher(_line);
String line = _line; String line = _line;
if (matcher.find()) { 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(); .replace(TIMESTAMP_REGEXP.toString(), "").trim();
} }

View File

@@ -141,4 +141,20 @@ public class UnifiedDiffReaderTest {
assertThat(diff.getTail()).isNull(); assertThat(diff.getTail()).isNull();
assertThat(diff.getHeader()).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();
}
} }

View File

@@ -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

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>io.github.java-diff-utils</groupId> <groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId> <artifactId>java-diff-utils-parent</artifactId>
<version>4.4</version> <version>4.5</version>
<name>java-diff-utils-parent</name> <name>java-diff-utils-parent</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
@@ -29,7 +29,7 @@
<connection>scm:git:https://github.com/java-diff-utils/java-diff-utils.git</connection> <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> <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> <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> </scm>
<issueManagement> <issueManagement>
<system>GitHub Issues</system> <system>GitHub Issues</system>