(c *C)
| 2297 | } |
| 2298 | |
| 2299 | func (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 | |
| 2351 | func (s *WorktreeSuite) TestRemove(c *C) { |
| 2352 | fs := memfs.New() |
nothing calls this directly
no test coverage detected