@@ -43,20 +43,20 @@ func (s *AttributeSource) String() string {
43
43
44
44
// GetRootAttributePaths beahves as GetRootAttributePaths, and loads information
45
45
// only from the global gitattributes file.
46
- func GetRootAttributePaths (cfg Env ) []AttributePath {
46
+ func GetRootAttributePaths (mp * gitattr. MacroProcessor , cfg Env ) []AttributePath {
47
47
af , ok := cfg .Get ("core.attributesfile" )
48
48
if ! ok {
49
49
return nil
50
50
}
51
51
52
52
// The working directory for the root gitattributes file is blank.
53
- return attrPaths (af , "" )
53
+ return attrPaths (mp , af , "" , true )
54
54
}
55
55
56
56
// GetSystemAttributePaths behaves as GetAttributePaths, and loads information
57
57
// only from the system gitattributes file, respecting the $PREFIX environment
58
58
// variable.
59
- func GetSystemAttributePaths (env Env ) []AttributePath {
59
+ func GetSystemAttributePaths (mp * gitattr. MacroProcessor , env Env ) []AttributePath {
60
60
prefix , _ := env .Get ("PREFIX" )
61
61
if len (prefix ) == 0 {
62
62
prefix = string (filepath .Separator )
@@ -68,24 +68,24 @@ func GetSystemAttributePaths(env Env) []AttributePath {
68
68
return nil
69
69
}
70
70
71
- return attrPaths (path , "" )
71
+ return attrPaths (mp , path , "" , true )
72
72
}
73
73
74
74
// GetAttributePaths returns a list of entries in .gitattributes which are
75
75
// configured with the filter=lfs attribute
76
76
// workingDir is the root of the working copy
77
77
// gitDir is the root of the git repo
78
- func GetAttributePaths (workingDir , gitDir string ) []AttributePath {
78
+ func GetAttributePaths (mp * gitattr. MacroProcessor , workingDir , gitDir string ) []AttributePath {
79
79
paths := make ([]AttributePath , 0 )
80
80
81
81
for _ , file := range findAttributeFiles (workingDir , gitDir ) {
82
- paths = append (paths , attrPaths (file .path , workingDir )... )
82
+ paths = append (paths , attrPaths (mp , file .path , workingDir , file . readMacros )... )
83
83
}
84
84
85
85
return paths
86
86
}
87
87
88
- func attrPaths (path , workingDir string ) []AttributePath {
88
+ func attrPaths (mp * gitattr. MacroProcessor , path , workingDir string , readMacros bool ) []AttributePath {
89
89
attributes , err := os .Open (path )
90
90
if err != nil {
91
91
return nil
@@ -103,6 +103,8 @@ func attrPaths(path, workingDir string) []AttributePath {
103
103
return nil
104
104
}
105
105
106
+ lines = mp .ProcessLines (lines , readMacros )
107
+
106
108
for _ , line := range lines {
107
109
lockable := false
108
110
tracked := false
@@ -145,7 +147,7 @@ func attrPaths(path, workingDir string) []AttributePath {
145
147
// workingDir is the root of the working copy
146
148
// gitDir is the root of the git repo
147
149
func GetAttributeFilter (workingDir , gitDir string ) * filepathfilter.Filter {
148
- paths := GetAttributePaths (workingDir , gitDir )
150
+ paths := GetAttributePaths (gitattr . NewMacroProcessor (), workingDir , gitDir )
149
151
patterns := make ([]filepathfilter.Pattern , 0 , len (paths ))
150
152
151
153
for _ , path := range paths {
0 commit comments