Git Product home page Git Product logo

go-diff's Introduction

go-diff Build Status GoDoc

Diff parser and printer for Go.

Installing

go get -u github.com/sourcegraph/go-diff/diff

Usage

It doesn't actually compute a diff. It only reads in (and prints out, given a Go struct representation) unified diff output, such as the following. The corresponding data structure in Go is the diff.FileDiff struct.

--- oldname	2009-10-11 15:12:20.000000000 -0700
+++ newname	2009-10-11 15:12:30.000000000 -0700
@@ -1,3 +1,9 @@ Section Header
+This is an important
+notice! It should
+therefore be located at
+the beginning of this
+document!
+
 This part of the
 document has stayed the
 same from version to
@@ -5,16 +11,10 @@
 be shown if it doesn't
 change.  Otherwise, that
 would not be helping to
-compress the size of the
-changes.
-
-This paragraph contains
-text that is outdated.
-It will be deleted in the
-near future.
+compress anything.

go-diff's People

Contributors

beyang avatar craigfurman avatar crsdrw avatar dmitris avatar dmitshur avatar dvrkps avatar eseliger avatar freeformz avatar gbrik avatar keegancsmith avatar kwi-dk avatar leounity avatar mrnugget avatar neelance avatar samertm avatar sofiia-tesliuk avatar sqs avatar stephen avatar strum355 avatar yuxiang-zhang avatar zegl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-diff's Issues

tag the code with v1.0.0 (or v0.0.1 etc.)

@keegancsmith - would you consider tagging the code with v1.0.0 (or v0.5.0 if you prefer)? If you create a release, it will automatically tag the code. It will make using your (very helpful!) library somewhat easier to use with Go modules. Thanks.

Two cases of unreachable code.

This is fairly harmless, but vet reports 2 instances of unreachable code. It's causing the Travis build to fail.

$ go tool vet ./
diff/parse.go:369: unreachable code
diff/parse.go:441: unreachable code

Need an option to keep no newline message

Hi, I'm developing a GitHub CI program by using this package.

However, I faced this problem: I can't calculate the position precisely when the original source file has no newline in the end. The position parameter is defined in here.

diff --git a/foo.php b/foo.php
index 88f2483c..b58d7b34 100644
--- a/foo.php
+++ b/foo.php
@@ -1,6 +1,4 @@
-<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
+<?xml version="1.0" encoding="UTF-8"?>
 <i>
-    <?php
-    echo $dm->text;
-    ?>
-</i>
\ No newline at end of file
+    <d p="<?= $dm->p ?>"><?= \yii\bootstrap\Html::encode($dm->text) ?></d>
+</i>

In the hunk.Body we has no \ No newline at end of file message so that I couldn't figure out the right position for the new lines after that message.

Parsing of diffs on windows fails

Running the standard GNU diff tool on windows can produce diff output with CRLF line endings instead of LF line endings. This currently causes an error in this diff parser.

To reproduce, run the go-diff diagnostic tool on the attached diff:

go-diff -f sample_diff_win.txt

and get the following error:

err read file(0): line 3, char 116: bad hunk header: @@ -1,3 +1,9 @@

The parser uses an in-built line reader instead of bufio.Scanner which does not strip trailing CR characters from lines (unlike bufio.Scanner)

sample_diff_win.txt

Tests will only pass if user timezone is Pacific.

Some of the tests parse a diff with timestamps in Pacific timezone, and expect the printed output to match byte for byte. This only happens if users' system timezone happens to also be Pacific.

This is why Travis tests failed previously.

Tests should be improved to work regardless of users' system timezone.

This can be reproduced by doing:

$ TZ=US/Mountain go test -v sourcegraph.com/sourcegraph/go-diff/diff
=== RUN TestParseHunkNoChunksize
--- PASS: TestParseHunkNoChunksize (0.00s)
=== RUN TestParseHunksAndPrintHunks
--- PASS: TestParseHunksAndPrintHunks (0.00s)
=== RUN TestParseFileDiffAndPrintFileDiff
--- FAIL: TestParseFileDiffAndPrintFileDiff (0.00s)
    diff_test.go:129: sample_file.diff: printed file diff != original file diff

        # PrintFileDiff output:
        --- oldname 2009-10-11 16:12:20.000000000 -0600
        +++ newname 2009-10-11 16:12:30.000000000 -0600
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
         the other hand, a
         misspelled word isn't
         the end of the world.


        # Original:
        --- oldname 2009-10-11 15:12:20.000000000 -0700
        +++ newname 2009-10-11 15:12:30.000000000 -0700
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
         the other hand, a
         misspelled word isn't
         the end of the world.
    diff_test.go:129: sample_file_extended.diff: printed file diff != original file diff

        # PrintFileDiff output:
        diff --git a/vcs/git_cmd.go b/vcs/git_cmd.go
        index aa4de15..7c048ab 100644
        --- oldname 2009-10-11 16:12:20.000000000 -0600
        +++ newname 2009-10-11 16:12:30.000000000 -0600
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
         the other hand, a
         misspelled word isn't
         the end of the world.


        # Original:
        diff --git a/vcs/git_cmd.go b/vcs/git_cmd.go
        index aa4de15..7c048ab 100644
        --- oldname 2009-10-11 15:12:20.000000000 -0700
        +++ newname 2009-10-11 15:12:30.000000000 -0700
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
         the other hand, a
         misspelled word isn't
         the end of the world.
=== RUN TestParseMultiFileDiffAndPrintMultiFileDiff
--- FAIL: TestParseMultiFileDiffAndPrintMultiFileDiff (0.00s)
    diff_test.go:170: sample_multi_file.diff: printed multi-file diff != original multi-file diff

        # PrintMultiFileDiff output:
        diff --ruN a/oldname1 b/newname1
        old mode 0777
        new mode 0755
        --- oldname1    2009-10-11 16:12:20.000000000 -0600
        +++ newname1    2009-10-11 16:12:30.000000000 -0600
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
        diff --ruN a/oldname2 b/newname2
        --- oldname2    2009-10-11 16:12:20.000000000 -0600
        +++ newname2    2009-10-11 16:12:30.000000000 -0600
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
         the other hand, a
         misspelled word isn't
         the end of the world.


        # Original:
        diff --ruN a/oldname1 b/newname1
        old mode 0777
        new mode 0755
        --- oldname1    2009-10-11 15:12:20.000000000 -0700
        +++ newname1    2009-10-11 15:12:30.000000000 -0700
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
        diff --ruN a/oldname2 b/newname2
        --- oldname2    2009-10-11 15:12:20.000000000 -0700
        +++ newname2    2009-10-11 15:12:30.000000000 -0700
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
         the other hand, a
         misspelled word isn't
         the end of the world.
    diff_test.go:170: sample_multi_file_single.diff: printed multi-file diff != original multi-file diff

        # PrintMultiFileDiff output:
        diff --ruN a/oldname1 b/newname1
        --- oldname1    2009-10-11 16:12:20.000000000 -0600
        +++ newname1    2009-10-11 16:12:30.000000000 -0600
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On


        # Original:
        diff --ruN a/oldname1 b/newname1
        --- oldname1    2009-10-11 15:12:20.000000000 -0700
        +++ newname1    2009-10-11 15:12:30.000000000 -0700
        @@ -1,3 +1,9 @@
        +This is an important
        +notice! It should
        +therefore be located at
        +the beginning of this
        +document!
        +
         This part of the
         document has stayed the
         same from version to
        @@ -5,16 +11,10 @@
         be shown if it doesn't
         change.  Otherwise, that
         would not be helping to
        -compress the size of the
        -changes.
        -
        -This paragraph contains
        -text that is outdated.
        -It will be deleted in the
        -near future.
        +compress anything.

         It is important to spell
        -check this dokument. On
        +check this document. On
=== RUN TestNoNewlineAtEnd
--- PASS: TestNoNewlineAtEnd (0.00s)
=== RUN TestFileDiff_Stat
--- PASS: TestFileDiff_Stat (0.00s)
FAIL
exit status 1
FAIL    sourcegraph.com/sourcegraph/go-diff/diff    0.007s

Add support for parsing multi-file diffs affecting binary files.

Unless I'm missing something, it seems the multi-file diff parser skips over changes to binary files (/cc @gbbr). Consider the following multi-file diff:

diff --git a/README.md b/README.md
index 7b73e04..36cde13 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 Conception-go [![Build Status](https://travis-ci.org/shurcooL/Conception-go.svg?branch=master)](https://travis-ci.org/shurcooL/Conception-go)
 =============

+This is a change.
+
 This is a work in progress Go implementation of [Conception](https://github.com/shurcooL/Conception#demonstration).

 Conception is an experimental project. It's a platform for researching software development tools and techniques. It is driven by a set of guiding principles. Conception-go targets Go development.
diff --git a/data/Font.png b/data/Font.png
index 17a971d..599f8dd 100644
Binary files a/data/Font.png and b/data/Font.png differ
diff --git a/main.go b/main.go
index 1aced1e..98a982e 100644
--- a/main.go
+++ b/main.go
@@ -6710,6 +6710,8 @@ func init() {
 }

 func main() {
+   // Another plain text change.
+
    //defer profile.Start(profile.CPUProfile).Stop()
    //defer profile.Start(profile.MemProfile).Stop()

There are 3 files changed. Two text files (README.md and main.go), one binary file (data/Font.png).

However, if I execute diff.ParseMultiFileDiff on that diff, the output is a slice with just 2 *diff.FileDiff entries, for the two text files. The binary file change is not there.

Reproduce sample

package main

import (
    "fmt"
    "strings"

    "sourcegraph.com/sourcegraph/go-diff/diff"
)

// fileDiffName returns the name of a FileDiff.
func fileDiffName(fileDiff *diff.FileDiff) string {
    var origName, newName string
    if strings.HasPrefix(fileDiff.OrigName, "a/") {
        origName = fileDiff.OrigName[2:]
    }
    if strings.HasPrefix(fileDiff.NewName, "b/") {
        newName = fileDiff.NewName[2:]
    }
    switch {
    case origName != "" && newName != "" && origName == newName: // Modified.
        return newName
    case origName != "" && newName != "" && origName != newName: // Renamed.
        return origName + " -> " + newName
    case origName == "" && newName != "": // Added.
        return newName
    case origName != "" && newName == "": // Removed.
        return "~~" + origName + "~~"
    default:
        panic("unexpected, no names")
    }
}

func main() {
    b := []byte(input)
    var o string
    if fileDiffs, err := diff.ParseMultiFileDiff(b); err == nil {
        for _, fileDiff := range fileDiffs {
            o += "\n" + "## " + fileDiffName(fileDiff) + "\n"
            /*o += "\n```diff\n"
            if hunks, err := diff.PrintHunks(fileDiff.Hunks); err == nil {
                o += string(hunks)
            }
            o += "```\n"*/
        }
    } else {
        o += "\n```\n" + err.Error() + "\n```\n"
    }
    fmt.Println(o)
}

const input = `diff --git a/README.md b/README.md
index 7b73e04..36cde13 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 Conception-go [![Build Status](https://travis-ci.org/shurcooL/Conception-go.svg?branch=master)](https://travis-ci.org/shurcooL/Conception-go)
 =============

+This is a change.
+
 This is a work in progress Go implementation of [Conception](https://github.com/shurcooL/Conception#demonstration).

 Conception is an experimental project. It's a platform for researching software development tools and techniques. It is driven by a set of guiding principles. Conception-go targets Go development.
diff --git a/data/Font.png b/data/Font.png
index 17a971d..599f8dd 100644
Binary files a/data/Font.png and b/data/Font.png differ
diff --git a/main.go b/main.go
index 1aced1e..98a982e 100644
--- a/main.go
+++ b/main.go
@@ -6710,6 +6710,8 @@ func init() {
 }

 func main() {
+   // Another plain text change.
+
    //defer profile.Start(profile.CPUProfile).Stop()
    //defer profile.Start(profile.MemProfile).Stop()

`

Copy detection missing

The format of a diff that found something for --find-copies is currently not supported

Rename of repository not handled well

This might actually be a bug in go, but I'm reporting it here anyway, since this breaks things here for now.

Recently, this library movied from sourcegraph to github. However, using the old sourcegraph.com name is now broken:

$ go get -d sourcegraph.com/sourcegraph/go-diff
go: sourcegraph.com/sourcegraph/[email protected]: parsing go.mod: unexpected module path "github.com/sourcegraph/go-diff"
go: error loading module requirements

The obvious fix is to just use the new github.com import path, but this is not always trivial. In particular, when go-diff is pulled in by a dependency that has the old url, running go get -u to update dependencies fails with the same error.

I guess that the problem is that go does not gracefully support updating to a new version in this case and updating across a rename (so 0.5.0 -> 0.5.1) needs changing of the import path. I can't see an easy way to fix this on the go side of things, so perhaps the fix here is to have sourcegraph.com not publish the 0.5.1 release (only 0.5.0), though that would also mean that people might never realize they're using an outdated version...

(also, I couldn't actually find the code on sourcegraph.com anymore, http://sourcegraph.com/sourcegraph/go-diff gives a 404, but apparently go get still manages to access the files)

MultiFileDiffReader doesn’t handle messages in diff that certain files are only available in specific version.

In some unified diff files there are such lines as Only in {path}: {filename}, meaning that certain files are only available in specific version. Those messages aren’t handled in any way, except when those lines are just catched in FileDiff.Extended for next FileDiff in the file.
Are there any plans of handling these messages?

For example, those unique files can be picked up in next functions, representing them as FileDiff with only the value OrigName.

func (r *MultiFileDiffReader) ReadAllFiles() ([]*FileDiff, error)
func (r *MultiFileDiffReader) ReadFile() (*FileDiff, error)

Then for this file example, the output below for ReadAllFiles() would be expected.
my_diff.txt

diff -u source_a/file_1.txt  source_b/file_1.txt
--- source_a/file_1.txt   2020-07-28 12:54:18.000000000 +0000
+++ source_b/file_1.txt  2020-07-28 12:54:18.000000000 +0000
@@ -2,3 +3,4 @@
 To be, or not to be, that is the question:
-Whether 'tis nobler in the mind to suffer
+The slings and arrows of outrageous fortune,
+Or to take arms against a sea of troubles
 And by opposing end them. To die—to sleep,
Only in source_a: file_2.txt
Only in source_b: file_3.txt
ReadAllFiles(myMultiFileDiffReader) -> {
    FileDiff{
        OrigName: “source_a/file_1.txt”, 
        OrigTime: ..., 
        NewName: “source_b/file_1.txt”, 
        NewTime: …,
        Entended: ..., 
        Hunks: …
    },
 
    FileDiff{
        OrigName: “source_a/file_2.txt”, 
        OrigTime: nil, 
        NewName: nil, 
        NewTime: nil
        …
    }, 

    FileDiff{
        OrigName: “source_b/file_3.txt”, 
        OrigTime: nil, 
        NewName: nil, 
        …
    }

}, nil

can't parse patch: parsing time

parsing time \"2022-08-24 14:35:19\" as \"2006-01-02 15:04:05 -0700\": cannot parse \"\" as \"-0700\""

diff:

➜ diff --version
Apple diff (based on FreeBSD diff)

No proper handling for special characters in file names

If a filename contains whitespace or other nonprintable characters, that field will be quoted in the manner of a C string literal: surrounded by ASCII double quote (34) characters, and with interior special characters backslash-escaped.

diff: latest release version still has old module path

The import path of this package has changed in PR #30. /cc @sqs

However, the latest released version (v0.5.0) still has the old module path in its go.mod file:

https://github.com/sourcegraph/go-diff/blob/v0.5.0/go.mod#L1

As a result, trying to install the latest version of this package in module mode fails:

$ cd $(mktemp -d)

$ go mod init m
go: creating new go.mod: module m

$ go get github.com/sourcegraph/go-diff/diff
go: finding github.com/sourcegraph/go-diff/diff latest
go: github.com/sourcegraph/[email protected]: parsing go.mod: unexpected module path "sourcegraph.com/sourcegraph/go-diff"
go: error loading module requirements

$ echo $?
1

This can be fixed this by making a new release version (perhaps v0.5.1) that contains the new module path in the go.mod file.

License is truncated

Hi! I was looking at your project and I noticed the license ends abruptly:

furnished to do so, subject to the following conditions:

Passthrough for non-diff output

I've recently started using this library, to redact diffs that pertain to secret files from logs. It would be great if (Multi)FileDiffReader could yield content that is not part of a valid diff, so that the caller has the choice of whether or not to print it.

For example, the program colordiff will successfully print non-diff output, allowing it to be used to process input that is mixed diff and non-diff content.

What do you think of this feature, and would you be interested in a PR that implements it?

Binary support v1

Binary diffs are parsed correctly after #46, but we should still add support to get the decoded body, and a boolean flag to determine a file is binary.

nil-panic when parsing diffs in which lines starting with `--` were removed

PR #53 introduced behaviour that tries to detect new file headers while parsing hunks.

The problem is that it breaks the parsing of diffs like these:

diff --git a/foobar.sql b/foobar.sql
index 55140ba..236cd59 100644
--- a/foobar.sql
+++ b/foobar.sql
@@ -1,4 +1,3 @@
 select 1;
--- this is my query
 select 2;
 select 3;

If we try to parse this we get a nil-panic:

goroutine 20 [running]:
testing.tRunner.func1.1(0x11af8c0, 0x130cc70)
        /Users/thorstenball/.asdf/installs/golang/1.15/go/src/testing/testing.go:1057 +0x30d
testing.tRunner.func1(0xc00021e480)
        /Users/thorstenball/.asdf/installs/golang/1.15/go/src/testing/testing.go:1060 +0x41a
panic(0x11af8c0, 0x130cc70)
        /Users/thorstenball/.asdf/installs/golang/1.15/go/src/runtime/panic.go:969 +0x175
github.com/sourcegraph/go-diff/diff.(*MultiFileDiffReader).ReadFile(0xc000104ee8, 0x0, 0x0, 0x0)
        /Users/thorstenball/work/go-diff/diff/parse.go:77 +0x193
github.com/sourcegraph/go-diff/diff.TestParseWithoutNilPanic(0xc00021e480)
        /Users/thorstenball/work/go-diff/diff/diff_test.go:900 +0x2e7
testing.tRunner(0xc00021e480, 0x11e81e0)
        /Users/thorstenball/.asdf/installs/golang/1.15/go/src/testing/testing.go:1108 +0xef
created by testing.(*T).Run
        /Users/thorstenball/.asdf/installs/golang/1.15/go/src/testing/testing.go:1159 +0x386
FAIL    github.com/sourcegraph/go-diff/diff     0.161s
FAIL

The nil panic comes from a missing return here:

go-diff/diff/parse.go

Lines 60 to 64 in 96789e3

case *ParseError:
if e.Err == ErrNoFileHeader || e.Err == ErrExtendedHeadersEOF {
return nil, io.EOF
}

But the underlying cause is that we abort the parsing of the diff once we hit the --.

Remove sourcegraph.com vanity import path

This package is currently accessible via sourcegraph.com/sourcegraph/go-diff but there isn't really a good reason for this, and we no longer serve vanity import paths at e.g. https://sourcegraph.com/sourcegraph/go-diff (the real location is now https://sourcegraph.com/github.com/sourcegraph/go-diff)

This package is in use by the Go build bots, it looks like: https://github.com/golang/build/blob/master/go.mod#L74

Some firewalls block Cloudflare, which Sourcegraph.com is hosted through -- making this package hard to fetch needlessly. Reported on Slack here: https://gophers.slack.com/archives/C9BMAAFFB/p1542362482359900

A PR for this would be very much appreciated :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.