diff options
author | Fabian Sabau <fabian.sabau+git@gmail.com> | 2019-03-04 12:55:58 +0100 |
---|---|---|
committer | Fabian Sabau <fabian.sabau+git@gmail.com> | 2019-03-04 12:55:58 +0100 |
commit | b2e0af997b79f45e99de4330473f110f01b68681 (patch) | |
tree | 94d4bb6c6281d92fec6cd4753cd2db2131983dfd | |
parent | bf0d56e7f2ce9b6538fb8a75fbdc2bcea1bc2995 (diff) | |
download | go-git-b2e0af997b79f45e99de4330473f110f01b68681.tar.gz |
worktree: test hardcoded excludes when no gitignore is present
Signed-off-by: Fabian Sabau <fabian.sabau+git@gmail.com>
-rw-r--r-- | worktree_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go index 872cd82..afedc91 100644 --- a/worktree_test.go +++ b/worktree_test.go @@ -1129,6 +1129,34 @@ func (s *WorktreeSuite) TestIgnored(c *C) { c.Assert(file.Worktree, Equals, Untracked) } +func (s *WorktreeSuite) TestExcludedNoGitignore(c *C) { + f := fixtures.ByTag("empty").One() + r := s.NewRepository(f) + + fs := memfs.New() + w := &Worktree{ + r: r, + Filesystem: fs, + } + + _, err := fs.Open(".gitignore") + c.Assert(err, Equals, os.ErrNotExist) + + w.Excludes = make([]gitignore.Pattern, 0) + w.Excludes = append(w.Excludes, gitignore.ParsePattern("foo", nil)) + + err = util.WriteFile(w.Filesystem, "foo", []byte("FOO"), 0755) + c.Assert(err, IsNil) + + status, err := w.Status() + c.Assert(err, IsNil) + c.Assert(status, HasLen, 0) + + file := status.File("foo") + c.Assert(file.Staging, Equals, Untracked) + c.Assert(file.Worktree, Equals, Untracked) +} + func (s *WorktreeSuite) TestAddModified(c *C) { fs := memfs.New() w := &Worktree{ |