MCPcopy Create free account
hub / github.com/go-git/go-git / TestTreeDiff

Method TestTreeDiff

plumbing/object/tree_test.go:271–296  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

269}
270
271func (s *TreeSuite) TestTreeDiff(c *C) {
272 f := fixtures.ByURL("https://github.com/src-d/go-git.git").One()
273 storer := filesystem.NewStorage(f.DotGit(), cache.NewObjectLRUDefault())
274 commit, err := GetCommit(storer, plumbing.NewHash("89f8bda31d29767a6d6ba8f9d0dfb941d598e843"))
275 c.Assert(err, IsNil)
276
277 tree, err := commit.Tree()
278 c.Assert(err, IsNil)
279
280 parentCommit, err := commit.Parent(0)
281 c.Assert(err, IsNil)
282
283 parentTree, err := parentCommit.Tree()
284 c.Assert(err, IsNil)
285
286 ch, err := parentTree.Diff(tree)
287 c.Assert(err, IsNil)
288
289 c.Assert(ch, HasLen, 3)
290 c.Assert(ch[0].From.Name, Equals, "examples/object_storage/main.go")
291 c.Assert(ch[0].To.Name, Equals, "examples/storage/main.go")
292
293 ch, err = parentTree.DiffContext(context.Background(), tree)
294 c.Assert(err, IsNil)
295 c.Assert(ch, HasLen, 3)
296}
297
298func (s *TreeSuite) TestTreeIter(c *C) {
299 encIter, err := s.Storer.IterEncodedObjects(plumbing.TreeObject)

Callers

nothing calls this directly

Calls 8

NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
NewHashFunction · 0.92
GetCommitFunction · 0.85
ParentMethod · 0.80
DiffMethod · 0.80
DiffContextMethod · 0.80
TreeMethod · 0.65

Tested by

no test coverage detected