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

Method TestReset

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

Source from the content-addressed store, hash-verified

1053}
1054
1055func (s *WorktreeSuite) TestReset(c *C) {
1056 fs := memfs.New()
1057 w := &Worktree{
1058 r: s.Repository,
1059 Filesystem: fs,
1060 }
1061
1062 commit := plumbing.NewHash("35e85108805c84807bc66a02d91535e1e24b38b9")
1063
1064 err := w.Checkout(&CheckoutOptions{})
1065 c.Assert(err, IsNil)
1066
1067 branch, err := w.r.Reference(plumbing.Master, false)
1068 c.Assert(err, IsNil)
1069 c.Assert(branch.Hash(), Not(Equals), commit)
1070
1071 err = w.Reset(&ResetOptions{Mode: MergeReset, Commit: commit})
1072 c.Assert(err, IsNil)
1073
1074 branch, err = w.r.Reference(plumbing.Master, false)
1075 c.Assert(err, IsNil)
1076 c.Assert(branch.Hash(), Equals, commit)
1077
1078 status, err := w.Status()
1079 c.Assert(err, IsNil)
1080 c.Assert(status.IsClean(), Equals, true)
1081}
1082
1083func (s *WorktreeSuite) TestResetWithUntracked(c *C) {
1084 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