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

Method TestReset

worktree_test.go:1169–1195  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

1167}
1168
1169func (s *WorktreeSuite) TestReset(c *C) {
1170 fs := memfs.New()
1171 w := &Worktree{
1172 r: s.Repository,
1173 Filesystem: fs,
1174 }
1175
1176 commit := plumbing.NewHash("35e85108805c84807bc66a02d91535e1e24b38b9")
1177
1178 err := w.Checkout(&CheckoutOptions{})
1179 c.Assert(err, IsNil)
1180
1181 branch, err := w.r.Reference(plumbing.Master, false)
1182 c.Assert(err, IsNil)
1183 c.Assert(branch.Hash(), Not(Equals), commit)
1184
1185 err = w.Reset(&ResetOptions{Mode: MergeReset, Commit: commit})
1186 c.Assert(err, IsNil)
1187
1188 branch, err = w.r.Reference(plumbing.Master, false)
1189 c.Assert(err, IsNil)
1190 c.Assert(branch.Hash(), Equals, commit)
1191
1192 status, err := w.Status()
1193 c.Assert(err, IsNil)
1194 c.Assert(status.IsClean(), Equals, true)
1195}
1196
1197func (s *WorktreeSuite) TestResetWithUntracked(c *C) {
1198 fs := memfs.New()

Callers

nothing calls this directly

Calls 7

CheckoutMethod · 0.95
ResetMethod · 0.95
StatusMethod · 0.95
NewHashFunction · 0.92
ReferenceMethod · 0.65
HashMethod · 0.65
IsCleanMethod · 0.45

Tested by

no test coverage detected