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

Method TestAddSkipStatusWithIgnoredPath

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

Source from the content-addressed store, hash-verified

2297}
2298
2299func (s *WorktreeSuite) TestAddSkipStatusWithIgnoredPath(c *C) {
2300 fs := memfs.New()
2301 w := &Worktree{
2302 r: s.Repository,
2303 Filesystem: fs,
2304 }
2305
2306 err := w.Checkout(&CheckoutOptions{Force: true})
2307 c.Assert(err, IsNil)
2308
2309 idx, err := w.r.Storer.Index()
2310 c.Assert(err, IsNil)
2311 c.Assert(idx.Entries, HasLen, 9)
2312
2313 err = util.WriteFile(fs, ".gitignore", []byte("fileToIgnore\n"), 0755)
2314 c.Assert(err, IsNil)
2315 _, err = w.Add(".gitignore")
2316 c.Assert(err, IsNil)
2317 _, err = w.Commit("Added .gitignore", defaultTestCommitOptions())
2318 c.Assert(err, IsNil)
2319
2320 err = util.WriteFile(fs, "fileToIgnore", []byte("file to ignore"), 0644)
2321 c.Assert(err, IsNil)
2322
2323 status, err := w.Status()
2324 c.Assert(err, IsNil)
2325 c.Assert(status, HasLen, 0)
2326
2327 file := status.File("fileToIgnore")
2328 c.Assert(file.Staging, Equals, Untracked)
2329 c.Assert(file.Worktree, Equals, Untracked)
2330
2331 err = w.AddWithOptions(&AddOptions{Path: "fileToIgnore", SkipStatus: true})
2332 c.Assert(err, IsNil)
2333
2334 idx, err = w.r.Storer.Index()
2335 c.Assert(err, IsNil)
2336 c.Assert(idx.Entries, HasLen, 10)
2337
2338 e, err := idx.Entry("fileToIgnore")
2339 c.Assert(err, IsNil)
2340 c.Assert(e.Mode, Equals, filemode.Regular)
2341
2342 status, err = w.Status()
2343 c.Assert(err, IsNil)
2344 c.Assert(status, HasLen, 1)
2345
2346 file = status.File("fileToIgnore")
2347 c.Assert(file.Staging, Equals, Added)
2348 c.Assert(file.Worktree, Equals, Unmodified)
2349}
2350
2351func (s *WorktreeSuite) TestRemove(c *C) {
2352 fs := memfs.New()

Callers

nothing calls this directly

Calls 9

CheckoutMethod · 0.95
AddMethod · 0.95
CommitMethod · 0.95
StatusMethod · 0.95
AddWithOptionsMethod · 0.95
defaultTestCommitOptionsFunction · 0.85
EntryMethod · 0.80
IndexMethod · 0.65
FileMethod · 0.45

Tested by

no test coverage detected