MCPcopy Index your code
hub / github.com/go-git/go-git / TestCommitAmendNothingToCommit

Method TestCommitAmendNothingToCommit

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

Source from the content-addressed store, hash-verified

252}
253
254func (s *WorktreeSuite) TestCommitAmendNothingToCommit(c *C) {
255 fs := memfs.New()
256 w := &Worktree{
257 r: s.Repository,
258 Filesystem: fs,
259 }
260
261 err := w.Checkout(&CheckoutOptions{})
262 c.Assert(err, IsNil)
263
264 err = util.WriteFile(fs, "foo", []byte("foo"), 0644)
265 c.Assert(err, IsNil)
266
267 _, err = w.Add("foo")
268 c.Assert(err, IsNil)
269
270 prevHash, err := w.Commit("foo\n", &CommitOptions{Author: defaultSignature()})
271 c.Assert(err, IsNil)
272
273 _, err = w.Commit("bar\n", &CommitOptions{Author: defaultSignature(), AllowEmptyCommits: true})
274 c.Assert(err, IsNil)
275
276 amendedHash, err := w.Commit("foo\n", &CommitOptions{Author: defaultSignature(), Amend: true})
277 c.Log(prevHash, amendedHash)
278 c.Assert(err, Equals, ErrEmptyCommit)
279 c.Assert(amendedHash, Equals, plumbing.ZeroHash)
280}
281
282func (s *WorktreeSuite) TestAddAndCommitWithSkipStatus(c *C) {
283 expected := plumbing.NewHash("375a3808ffde7f129cdd3c8c252fd0fe37cfd13b")

Callers

nothing calls this directly

Calls 5

CheckoutMethod · 0.95
AddMethod · 0.95
CommitMethod · 0.95
defaultSignatureFunction · 0.85
LogMethod · 0.80

Tested by

no test coverage detected