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

Method TestResetHard

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

Source from the content-addressed store, hash-verified

1312}
1313
1314func (s *WorktreeSuite) TestResetHard(c *C) {
1315 fs := memfs.New()
1316 w := &Worktree{
1317 r: s.Repository,
1318 Filesystem: fs,
1319 }
1320
1321 commit := plumbing.NewHash("35e85108805c84807bc66a02d91535e1e24b38b9")
1322
1323 err := w.Checkout(&CheckoutOptions{})
1324 c.Assert(err, IsNil)
1325
1326 f, err := fs.Create(".gitignore")
1327 c.Assert(err, IsNil)
1328 _, err = f.Write([]byte("foo"))
1329 c.Assert(err, IsNil)
1330 err = f.Close()
1331 c.Assert(err, IsNil)
1332
1333 err = w.Reset(&ResetOptions{Mode: HardReset, Commit: commit})
1334 c.Assert(err, IsNil)
1335
1336 branch, err := w.r.Reference(plumbing.Master, false)
1337 c.Assert(err, IsNil)
1338 c.Assert(branch.Hash(), Equals, commit)
1339}
1340
1341func (s *WorktreeSuite) TestResetHardSubFolders(c *C) {
1342 fs := memfs.New()

Callers

nothing calls this directly

Calls 8

CheckoutMethod · 0.95
ResetMethod · 0.95
NewHashFunction · 0.92
CloseMethod · 0.65
ReferenceMethod · 0.65
HashMethod · 0.65
CreateMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected