aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/tree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-04-25 12:36:40 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2020-04-25 12:36:40 +0200
commit042e56e56e644bc9f02780dbf6eeadc40eb57f6a (patch)
treeb384712a73068ae5f4945385fac7b45752f6dd7c /plumbing/object/tree_test.go
parentc9533a6f9f3a6edd0fb7c8c161d4016a6af26bc3 (diff)
downloadgo-git-042e56e56e644bc9f02780dbf6eeadc40eb57f6a.tar.gz
plumbing: object, make renames diff default
Diffstat (limited to 'plumbing/object/tree_test.go')
-rw-r--r--plumbing/object/tree_test.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/plumbing/object/tree_test.go b/plumbing/object/tree_test.go
index 319caae..474bb6a 100644
--- a/plumbing/object/tree_test.go
+++ b/plumbing/object/tree_test.go
@@ -1,9 +1,11 @@
package object
import (
+ "context"
"errors"
"io"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/filemode"
@@ -11,7 +13,6 @@ import (
"github.com/go-git/go-git/v5/storage/filesystem"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type TreeSuite struct {
@@ -240,6 +241,33 @@ func (s *TreeSuite) TestTreeDecodeEncodeIdempotent(c *C) {
}
}
+func (s *TreeSuite) TestTreeDiff(c *C) {
+ f := fixtures.ByURL("https://github.com/src-d/go-git.git").One()
+ storer := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
+ commit, err := GetCommit(storer, plumbing.NewHash("89f8bda31d29767a6d6ba8f9d0dfb941d598e843"))
+ c.Assert(err, IsNil)
+
+ tree, err := commit.Tree()
+ c.Assert(err, IsNil)
+
+ parentCommit, err := commit.Parent(0)
+ c.Assert(err, IsNil)
+
+ parentTree, err := parentCommit.Tree()
+ c.Assert(err, IsNil)
+
+ ch, err := parentTree.Diff(tree)
+ c.Assert(err, IsNil)
+
+ c.Assert(ch, HasLen, 3)
+ c.Assert(ch[0].From.Name, Equals, "examples/object_storage/main.go")
+ c.Assert(ch[0].To.Name, Equals, "examples/storage/main.go")
+
+ ch, err = parentTree.DiffContext(context.Background(), tree)
+ c.Assert(err, IsNil)
+ c.Assert(ch, HasLen, 3)
+}
+
func (s *TreeSuite) TestTreeIter(c *C) {
encIter, err := s.Storer.IterEncodedObjects(plumbing.TreeObject)
c.Assert(err, IsNil)