diffparser icon indicating copy to clipboard operation
diffparser copied to clipboard

Fixed panic on diffparser when first line is invalid

Open mazen160 opened this issue 3 years ago • 0 comments

There is a panic that is not caught on the latest release of diffparser that is not caught by error handling.

I have introduced in my tool, and thought to share the fix with everyone, and hopefully to have it merged soon.

How to produce the panic?

The diff_raw is missing diff --git a/file.txt b/file.txt

	var diff_raw string = `
new file mode 100644
index 0000000..814b5ab
--- /dev/null
+++ b/file.txt
@@ -0,0 +1,4 @@
+Hello world`

diff, err := diffparser.Parse(diff_raw)
if err != nill {
  error.Wrapf("handled successfully", err)
}

Best Regards, Mazin

mazen160 avatar Aug 12 '21 16:08 mazen160