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

Method TestNothingToCommit

worktree_commit_test.go:74–90  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

72}
73
74func (s *WorktreeSuite) TestNothingToCommit(c *C) {
75 expected := plumbing.NewHash("838ea833ce893e8555907e5ef224aa076f5e274a")
76
77 r, err := Init(memory.NewStorage(), memfs.New())
78 c.Assert(err, IsNil)
79
80 w, err := r.Worktree()
81 c.Assert(err, IsNil)
82
83 hash, err := w.Commit("failed empty commit\n", &CommitOptions{Author: defaultSignature()})
84 c.Assert(hash, Equals, plumbing.ZeroHash)
85 c.Assert(err, Equals, ErrEmptyCommit)
86
87 hash, err = w.Commit("enable empty commits\n", &CommitOptions{Author: defaultSignature(), AllowEmptyCommits: true})
88 c.Assert(hash, Equals, expected)
89 c.Assert(err, IsNil)
90}
91
92func (s *WorktreeSuite) TestCommitParent(c *C) {
93 expected := plumbing.NewHash("ef3ca05477530b37f48564be33ddd48063fc7a22")

Callers

nothing calls this directly

Calls 6

NewHashFunction · 0.92
NewStorageFunction · 0.92
InitFunction · 0.85
defaultSignatureFunction · 0.85
WorktreeMethod · 0.80
CommitMethod · 0.65

Tested by

no test coverage detected