MCPcopy Index your code
hub / github.com/go-git/go-git / TestAddRemovedInDirectory

Method TestAddRemovedInDirectory

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

Source from the content-addressed store, hash-verified

1805}
1806
1807func (s *WorktreeSuite) TestAddRemovedInDirectory(c *C) {
1808 fs := memfs.New()
1809 w := &Worktree{
1810 r: s.Repository,
1811 Filesystem: fs,
1812 }
1813
1814 err := w.Checkout(&CheckoutOptions{Force: true})
1815 c.Assert(err, IsNil)
1816
1817 idx, err := w.r.Storer.Index()
1818 c.Assert(err, IsNil)
1819 c.Assert(idx.Entries, HasLen, 9)
1820
1821 err = w.Filesystem.Remove("go/example.go")
1822 c.Assert(err, IsNil)
1823
1824 err = w.Filesystem.Remove("json/short.json")
1825 c.Assert(err, IsNil)
1826
1827 hash, err := w.Add("go")
1828 c.Assert(err, IsNil)
1829 c.Assert(hash.IsZero(), Equals, true)
1830
1831 e, err := idx.Entry("go/example.go")
1832 c.Assert(err, IsNil)
1833 c.Assert(e.Hash, Equals, plumbing.NewHash("880cd14280f4b9b6ed3986d6671f907d7cc2a198"))
1834 c.Assert(e.Mode, Equals, filemode.Regular)
1835
1836 e, err = idx.Entry("json/short.json")
1837 c.Assert(err, IsNil)
1838 c.Assert(e.Hash, Equals, plumbing.NewHash("c8f1d8c61f9da76f4cb49fd86322b6e685dba956"))
1839 c.Assert(e.Mode, Equals, filemode.Regular)
1840
1841 status, err := w.Status()
1842 c.Assert(err, IsNil)
1843 c.Assert(status, HasLen, 2)
1844
1845 file := status.File("go/example.go")
1846 c.Assert(file.Staging, Equals, Deleted)
1847
1848 file = status.File("json/short.json")
1849 c.Assert(file.Staging, Equals, Unmodified)
1850}
1851
1852func (s *WorktreeSuite) TestAddRemovedInDirectoryWithTrailingSlash(c *C) {
1853 fs := memfs.New()

Callers

nothing calls this directly

Calls 9

CheckoutMethod · 0.95
AddMethod · 0.95
StatusMethod · 0.95
NewHashFunction · 0.92
EntryMethod · 0.80
IndexMethod · 0.65
IsZeroMethod · 0.65
RemoveMethod · 0.45
FileMethod · 0.45

Tested by

no test coverage detected