Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnifiedDiffParserException: expected file start line not found #98

Closed
tomasbjerre opened this issue Sep 6, 2020 · 1 comment
Closed

Comments

@tomasbjerre
Copy link

tomasbjerre commented Sep 6, 2020

Describe the bug

I try to parse a patch-file, generated from git git format-patch -1 <commit>, with content:

From fd940c6f66126734e82c00889e7c987e11deea91 Mon Sep 17 00:00:00 2001
From: Tomas Bjerre <[email protected]>
Date: Sun, 6 Sep 2020 11:20:34 +0200
Subject: [PATCH] removing file

---
 .../violations/lib/model/ViolationTest.java   | 37 -------------------
 1 file changed, 37 deletions(-)
 delete mode 100644 src/test/java/se/bjurr/violations/lib/model/ViolationTest.java

diff --git a/src/test/java/se/bjurr/violations/lib/model/ViolationTest.java b/src/test/java/se/bjurr/violations/lib/model/ViolationTest.java
deleted file mode 100644
index 3e40b52..0000000
--- a/src/test/java/se/bjurr/violations/lib/model/ViolationTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package se.bjurr.violations.lib.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static se.bjurr.violations.lib.model.SEVERITY.ERROR;
-import static se.bjurr.violations.lib.model.Violation.violationBuilder;
-import static se.bjurr.violations.lib.reports.Parser.CHECKSTYLE;
-
-import org.junit.Test;
-import se.bjurr.violations.lib.model.Violation.ViolationBuilder;
-import uk.co.jemos.podam.api.PodamFactoryImpl;
-
-public class ViolationTest {
-
-  @Test
-  public void testThatFilePathsAreAlwaysFronSlashes() {
-    final Violation violation =
-        violationBuilder() //
-            .setParser(CHECKSTYLE) //
-            .setFile("c:\\path\\to\\file.xml") //
-            .setMessage("message") //
-            .setSeverity(ERROR) //
-            .setStartLine(1) //
-            .build();
-    assertThat(violation.getFile()) //
-        .isEqualTo("c:/path/to/file.xml");
-  }
-
-  @Test
-  public void testThatCopyConstructorWorks() {
-    final ViolationBuilder originalBuilder =
-        new PodamFactoryImpl().manufacturePojo(ViolationBuilder.class);
-    final Violation original = originalBuilder.build();
-    final Violation copied = new Violation(original);
-    assertThat(copied) //
-        .isEqualTo(original);
-  }
-}
-- 
2.25.1


I get error like:

com.github.difflib.unifieddiff.UnifiedDiffParserException: expected file start line not found
	at com.github.difflib.unifieddiff.UnifiedDiffReader.parse(UnifiedDiffReader.java:93)
	at com.github.difflib.unifieddiff.UnifiedDiffReader.parseUnifiedDiff(UnifiedDiffReader.java:144)

To Reproduce

Parse above data with:

    InputStream reportContentStream = new ByteArrayInputStream(reportContent.getBytes(UTF_8));
    UnifiedDiff parsedDiff = UnifiedDiffReader.parseUnifiedDiff(reportContentStream);

Expected behavior
Not to crash

System

  • Java version 1.8.0_171
  • Version 4.8-SNAPSHOT de04bd6

Relates to tomasbjerre/violations-lib#95

@wumpz
Copy link
Collaborator

wumpz commented Sep 27, 2020

The problem was the deleted file mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants