diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-04-25 12:36:40 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2020-04-25 12:36:40 +0200 |
commit | 042e56e56e644bc9f02780dbf6eeadc40eb57f6a (patch) | |
tree | b384712a73068ae5f4945385fac7b45752f6dd7c /plumbing/object/tree_test.go | |
parent | c9533a6f9f3a6edd0fb7c8c161d4016a6af26bc3 (diff) | |
download | go-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.go | 30 |
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) |