@@ -11,6 +11,7 @@ import (
11
11
12
12
type MatcherSuite struct {
13
13
GFS billy.Filesystem // git repository root
14
+ IEFS billy.Filesystem // git repository root using info/exclude instead
14
15
RFS billy.Filesystem // root that contains user home
15
16
MCFS billy.Filesystem // root that contains user home, but missing ~/.gitconfig
16
17
MEFS billy.Filesystem // root that contains user home, but missing excludesfile entry
@@ -53,6 +54,39 @@ func (s *MatcherSuite) SetUpTest(c *C) {
53
54
54
55
s .GFS = fs
55
56
57
+ // setup generic git repository root using info/exclude instead
58
+ fs = memfs .New ()
59
+ err = fs .MkdirAll (".git/info" , os .ModePerm )
60
+ c .Assert (err , IsNil )
61
+ f , err = fs .Create (".git/info/exclude" )
62
+ c .Assert (err , IsNil )
63
+ _ , err = f .Write ([]byte ("vendor/g*/\n " ))
64
+ c .Assert (err , IsNil )
65
+ _ , err = f .Write ([]byte ("ignore.crlf\r \n " ))
66
+ c .Assert (err , IsNil )
67
+ err = f .Close ()
68
+ c .Assert (err , IsNil )
69
+
70
+ err = fs .MkdirAll ("vendor" , os .ModePerm )
71
+ c .Assert (err , IsNil )
72
+ f , err = fs .Create ("vendor/.gitignore" )
73
+ c .Assert (err , IsNil )
74
+ _ , err = f .Write ([]byte ("!github.com/\n " ))
75
+ c .Assert (err , IsNil )
76
+ err = f .Close ()
77
+ c .Assert (err , IsNil )
78
+
79
+ err = fs .MkdirAll ("another" , os .ModePerm )
80
+ c .Assert (err , IsNil )
81
+ err = fs .MkdirAll ("ignore.crlf" , os .ModePerm )
82
+ c .Assert (err , IsNil )
83
+ err = fs .MkdirAll ("vendor/github.com" , os .ModePerm )
84
+ c .Assert (err , IsNil )
85
+ err = fs .MkdirAll ("vendor/gopkg.in" , os .ModePerm )
86
+ c .Assert (err , IsNil )
87
+
88
+ s .IEFS = fs
89
+
56
90
// setup root that contains user home
57
91
home , err := os .UserHomeDir ()
58
92
c .Assert (err , IsNil )
@@ -179,6 +213,15 @@ func (s *MatcherSuite) TestDir_ReadPatterns(c *C) {
179
213
c .Assert (m .Match ([]string {"ignore.crlf" }, true ), Equals , true )
180
214
c .Assert (m .Match ([]string {"vendor" , "gopkg.in" }, true ), Equals , true )
181
215
c .Assert (m .Match ([]string {"vendor" , "github.com" }, true ), Equals , false )
216
+
217
+ ps , err = ReadPatterns (s .IEFS , nil )
218
+ c .Assert (err , IsNil )
219
+ c .Assert (ps , HasLen , 3 )
220
+
221
+ m = NewMatcher (ps )
222
+ c .Assert (m .Match ([]string {"ignore.crlf" }, true ), Equals , true )
223
+ c .Assert (m .Match ([]string {"vendor" , "gopkg.in" }, true ), Equals , true )
224
+ c .Assert (m .Match ([]string {"vendor" , "github.com" }, true ), Equals , false )
182
225
}
183
226
184
227
func (s * MatcherSuite ) TestDir_LoadGlobalPatterns (c * C ) {
0 commit comments