aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorAlan D. Cabrera <adc@toolazydogs.com>2018-05-10 21:47:25 -0700
committerMáximo Cuadros <mcuadros@gmail.com>2018-05-11 06:47:25 +0200
commite63b032e91ce35e0ecd5f27d43be655625e8af36 (patch)
tree2270ae7d5e88e5443bfb486432bf04d1642170d6 /worktree_test.go
parent47417ae81f81e520b003fbe3166c5842d5acce91 (diff)
downloadgo-git-e63b032e91ce35e0ecd5f27d43be655625e8af36.tar.gz
Worktree: Provide ability to add excludes (#825)
Worktree: Provide ability to add excludes
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 05a205a..df191b0 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -15,6 +15,7 @@ import (
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
+ "gopkg.in/src-d/go-git.v4/plumbing/format/gitignore"
"gopkg.in/src-d/go-git.v4/plumbing/format/index"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/storage/memory"
@@ -1072,6 +1073,35 @@ func (s *WorktreeSuite) TestAddUntracked(c *C) {
c.Assert(obj.Size(), Equals, int64(3))
}
+func (s *WorktreeSuite) TestIgnored(c *C) {
+ fs := memfs.New()
+ w := &Worktree{
+ r: s.Repository,
+ Filesystem: fs,
+ }
+
+ w.Excludes = make([]gitignore.Pattern, 0)
+ w.Excludes = append(w.Excludes, gitignore.ParsePattern("foo", nil))
+
+ 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, "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{