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

Method TestAddModified

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

Source from the content-addressed store, hash-verified

1717}
1718
1719func (s *WorktreeSuite) TestAddModified(c *C) {
1720 fs := memfs.New()
1721 w := &Worktree{
1722 r: s.Repository,
1723 Filesystem: fs,
1724 }
1725
1726 err := w.Checkout(&CheckoutOptions{Force: true})
1727 c.Assert(err, IsNil)
1728
1729 idx, err := w.r.Storer.Index()
1730 c.Assert(err, IsNil)
1731 c.Assert(idx.Entries, HasLen, 9)
1732
1733 err = util.WriteFile(w.Filesystem, "LICENSE", []byte("FOO"), 0644)
1734 c.Assert(err, IsNil)
1735
1736 hash, err := w.Add("LICENSE")
1737 c.Assert(err, IsNil)
1738 c.Assert(hash.String(), Equals, "d96c7efbfec2814ae0301ad054dc8d9fc416c9b5")
1739
1740 idx, err = w.r.Storer.Index()
1741 c.Assert(err, IsNil)
1742 c.Assert(idx.Entries, HasLen, 9)
1743
1744 e, err := idx.Entry("LICENSE")
1745 c.Assert(err, IsNil)
1746 c.Assert(e.Hash, Equals, hash)
1747 c.Assert(e.Mode, Equals, filemode.Regular)
1748
1749 status, err := w.Status()
1750 c.Assert(err, IsNil)
1751 c.Assert(status, HasLen, 1)
1752
1753 file := status.File("LICENSE")
1754 c.Assert(file.Staging, Equals, Modified)
1755 c.Assert(file.Worktree, Equals, Unmodified)
1756}
1757
1758func (s *WorktreeSuite) TestAddUnmodified(c *C) {
1759 fs := memfs.New()

Callers

nothing calls this directly

Calls 7

CheckoutMethod · 0.95
AddMethod · 0.95
StatusMethod · 0.95
EntryMethod · 0.80
IndexMethod · 0.65
StringMethod · 0.65
FileMethod · 0.45

Tested by

no test coverage detected