MCPcopy
hub / github.com/go-git/go-git / TestCommitAmendWithoutChanges

Method TestCommitAmendWithoutChanges

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

Source from the content-addressed store, hash-verified

166}
167
168func (s *WorktreeSuite) TestCommitAmendWithoutChanges(c *C) {
169 fs := memfs.New()
170 w := &Worktree{
171 r: s.Repository,
172 Filesystem: fs,
173 }
174
175 err := w.Checkout(&CheckoutOptions{})
176 c.Assert(err, IsNil)
177
178 err = util.WriteFile(fs, "foo", []byte("foo"), 0644)
179 c.Assert(err, IsNil)
180
181 _, err = w.Add("foo")
182 c.Assert(err, IsNil)
183
184 prevHash, err := w.Commit("foo\n", &CommitOptions{Author: defaultSignature()})
185 c.Assert(err, IsNil)
186
187 amendedHash, err := w.Commit("foo\n", &CommitOptions{Author: defaultSignature(), Amend: true})
188 c.Assert(err, IsNil)
189
190 headRef, err := w.r.Head()
191 c.Assert(err, IsNil)
192
193 c.Assert(amendedHash, Equals, headRef.Hash())
194 c.Assert(amendedHash, Equals, prevHash)
195
196 commit, err := w.r.CommitObject(headRef.Hash())
197 c.Assert(err, IsNil)
198 c.Assert(commit.Message, Equals, "foo\n")
199
200 assertStorageStatus(c, s.Repository, 13, 11, 10, amendedHash)
201}
202
203func (s *WorktreeSuite) TestCommitAmendWithChanges(c *C) {
204 fs := memfs.New()

Callers

nothing calls this directly

Calls 8

CheckoutMethod · 0.95
AddMethod · 0.95
CommitMethod · 0.95
defaultSignatureFunction · 0.85
assertStorageStatusFunction · 0.85
HeadMethod · 0.80
CommitObjectMethod · 0.80
HashMethod · 0.65

Tested by

no test coverage detected