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

Method TestAddSkipStatusModifiedPath

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

Source from the content-addressed store, hash-verified

2226}
2227
2228func (s *WorktreeSuite) TestAddSkipStatusModifiedPath(c *C) {
2229 fs := memfs.New()
2230 w := &Worktree{
2231 r: s.Repository,
2232 Filesystem: fs,
2233 }
2234
2235 err := w.Checkout(&CheckoutOptions{Force: true})
2236 c.Assert(err, IsNil)
2237
2238 idx, err := w.r.Storer.Index()
2239 c.Assert(err, IsNil)
2240 c.Assert(idx.Entries, HasLen, 9)
2241
2242 err = util.WriteFile(w.Filesystem, "LICENSE", []byte("file1"), 0644)
2243 c.Assert(err, IsNil)
2244
2245 err = w.AddWithOptions(&AddOptions{Path: "LICENSE", SkipStatus: true})
2246 c.Assert(err, IsNil)
2247
2248 idx, err = w.r.Storer.Index()
2249 c.Assert(err, IsNil)
2250 c.Assert(idx.Entries, HasLen, 9)
2251
2252 e, err := idx.Entry("LICENSE")
2253 c.Assert(err, IsNil)
2254 c.Assert(e.Mode, Equals, filemode.Regular)
2255
2256 status, err := w.Status()
2257 c.Assert(err, IsNil)
2258 c.Assert(status, HasLen, 1)
2259
2260 file := status.File("LICENSE")
2261 c.Assert(file.Staging, Equals, Modified)
2262 c.Assert(file.Worktree, Equals, Unmodified)
2263}
2264
2265func (s *WorktreeSuite) TestAddSkipStatusNonModifiedPath(c *C) {
2266 fs := memfs.New()

Callers

nothing calls this directly

Calls 6

CheckoutMethod · 0.95
AddWithOptionsMethod · 0.95
StatusMethod · 0.95
EntryMethod · 0.80
IndexMethod · 0.65
FileMethod · 0.45

Tested by

no test coverage detected