7
7
"io/ioutil"
8
8
"regexp"
9
9
"strings"
10
-
11
- "gopkg.in/src-d/enry.v1/data"
12
10
)
13
11
14
12
type attrType int
@@ -28,6 +26,7 @@ func (i attrType) String() string {
28
26
if i < 0 || i >= attrType (len (attrTypeIndex )- 1 ) {
29
27
return fmt .Sprintf ("attrType(%d)" , i )
30
28
}
29
+
31
30
return attrTypeName [attrTypeIndex [i ]:attrTypeIndex [i + 1 ]]
32
31
}
33
32
@@ -42,7 +41,8 @@ type regExpAttribute struct {
42
41
attributes map [* regexp.Regexp ]string
43
42
}
44
43
45
- // GitAttributes is a struct that contains two maps, boolAttributes contains all the attributes that works like a boolean condition,
44
+ // GitAttributes is a struct that contains two maps:
45
+ // boolAttributes contains all the attributes that works like a boolean condition,
46
46
// regExpAttributes contains all the attributes that match a regExp to choose if an attribute is applied or not
47
47
type GitAttributes struct {
48
48
boolAttributes map [attrType ]boolAttribute
@@ -64,7 +64,7 @@ func (gitAttrs *GitAttributes) IsVendor(path string) bool {
64
64
return val
65
65
}
66
66
67
- return data . VendorMatchers . Match (path )
67
+ return IsVendor (path )
68
68
}
69
69
70
70
// Returns whether or not path is a documentation path.
@@ -73,7 +73,7 @@ func (gitAttrs *GitAttributes) IsDocumentation(path string) bool {
73
73
return val
74
74
}
75
75
76
- return data . DocumentationMatchers . Match (path )
76
+ return IsDocumentation (path )
77
77
}
78
78
79
79
// Returns whether or not path is a generated path.
@@ -113,8 +113,8 @@ func NewGitAttributes() *GitAttributes {
113
113
return & gitAttrs
114
114
}
115
115
116
- // LoadGitattributes reads and parses the file .gitattributes which overrides the standard strategies
117
- // Returns slice of errors that have may ocurred in the load
116
+ // LoadGitattributes reads and parses the file .gitattributes which overrides the standard strategies.
117
+ // Returns slice of errors that have may ocurred in the load.
118
118
func (gitAttrs * GitAttributes ) LoadGitAttributes (path string , reader io.Reader ) []error {
119
119
rawAttributes , errArr := loadRawGitAttributes (reader )
120
120
if len (rawAttributes ) == 0 {
@@ -124,19 +124,6 @@ func (gitAttrs *GitAttributes) LoadGitAttributes(path string, reader io.Reader)
124
124
return append (gitAttrs .parseAttributes (path , rawAttributes ), errArr ... )
125
125
}
126
126
127
- func (gitAttrs * GitAttributes ) String () string {
128
- out := ""
129
- for key , val := range gitAttrs .boolAttributes {
130
- out += fmt .Sprintf ("Type: %s Attributes: %v\n " , key , val .attributes )
131
- }
132
-
133
- for key , val := range gitAttrs .regExpAttributes {
134
- out += fmt .Sprintf ("Type: %s Attributes: %v\n " , key , val .attributes )
135
- }
136
-
137
- return out
138
- }
139
-
140
127
func loadRawGitAttributes (reader io.Reader ) (map [string ][]string , []error ) {
141
128
rawAttributes := map [string ][]string {}
142
129
var errArr []error
@@ -216,6 +203,7 @@ func (gitAttrs *GitAttributes) processBoolAttr(kind attrType, key string, attrib
216
203
if _ , ok := gitAttrs .boolAttributes [kind ].attributes [key ]; ok {
217
204
err = & overrideError {attribute : kind , path : key }
218
205
}
206
+
219
207
switch {
220
208
case attribute == gitAttrs .boolAttributes [kind ].matchers [0 ]:
221
209
gitAttrs .boolAttributes [kind ].attributes [key ] = true
0 commit comments