diff options
author | jk2k <4025839+jk2K@users.noreply.github.com> | 2020-06-07 20:06:33 +0800 |
---|---|---|
committer | jk2k <4025839+jk2K@users.noreply.github.com> | 2020-06-10 20:26:51 +0800 |
commit | e4a55327a2f1bd53fa173ce3e536eef530bfc272 (patch) | |
tree | b9f9f33604905b135b79667a14f36d5d3c90912e /worktree_test.go | |
parent | 96a108e35075afd13e81df9ba2bf96c8c6125283 (diff) | |
download | go-git-e4a55327a2f1bd53fa173ce3e536eef530bfc272.tar.gz |
feat: add file with using .gitignore, fixed src-d/go-git#1219
Diffstat (limited to 'worktree_test.go')
-rw-r--r-- | worktree_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go index 24a65eb..2ee830a 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -1370,6 +1370,52 @@ func (s *WorktreeSuite) TestAddDirectoryErrorNotFound(c *C) { c.Assert(h.IsZero(), Equals, true) } +func (s *WorktreeSuite) TestAddAll(c *C) { + fs := memfs.New() + w := &Worktree{ + r: s.Repository, + Filesystem: fs, + } + + err := w.Checkout(&CheckoutOptions{Force: true}) + c.Assert(err, IsNil) + + idx, err := w.r.Storer.Index() + c.Assert(err, IsNil) + c.Assert(idx.Entries, HasLen, 9) + + err = util.WriteFile(w.Filesystem, "file1", []byte("file1"), 0644) + c.Assert(err, IsNil) + + err = util.WriteFile(w.Filesystem, "file2", []byte("file2"), 0644) + c.Assert(err, IsNil) + + err = util.WriteFile(w.Filesystem, "file3", []byte("ignore me"), 0644) + c.Assert(err, IsNil) + + w.Excludes = make([]gitignore.Pattern, 0) + w.Excludes = append(w.Excludes, gitignore.ParsePattern("file3", nil)) + + _, err = w.AddWithOptions(&AddOptions{All: true}) + c.Assert(err, IsNil) + + idx, err = w.r.Storer.Index() + c.Assert(err, IsNil) + c.Assert(idx.Entries, HasLen, 11) + + status, err := w.Status() + c.Assert(err, IsNil) + c.Assert(status, HasLen, 2) + + file1 := status.File("file1") + c.Assert(file1.Staging, Equals, Added) + file2 := status.File("file2") + c.Assert(file2.Staging, Equals, Added) + file3 := status.File("file3") + c.Assert(file3.Staging, Equals, Untracked) + c.Assert(file3.Worktree, Equals, Untracked) +} + func (s *WorktreeSuite) TestAddGlob(c *C) { fs := memfs.New() w := &Worktree{ |