-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: improve pack performance, implement tree pruning #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,22 +74,28 @@ func readRules(input io.Reader) []rule { | |
return rules | ||
} | ||
|
||
func matchIgnoreRule(path string, rules []rule) bool { | ||
matched := false | ||
func matchIgnoreRule(path string, rules []rule) (bool, *rule) { | ||
var matched *rule = nil | ||
path = filepath.FromSlash(path) | ||
for _, rule := range rules { | ||
for idx := range rules { | ||
rule := &rules[idx] | ||
Comment on lines
+80
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't know if there's an idiomatic go way to express this, but this is a pretty significant performance improvement |
||
match, _ := rule.match(path) | ||
|
||
if match { | ||
matched = !rule.excluded | ||
if rule.excluded { | ||
return false, rule | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This precedence matches |
||
} | ||
if rule.val != "**/*" || matched == nil { | ||
matched = rule | ||
} | ||
} | ||
} | ||
|
||
if matched { | ||
if matched != nil { | ||
debug(true, path, "Skipping excluded path:", path) | ||
} | ||
|
||
return matched | ||
return matched != nil, matched | ||
} | ||
|
||
type rule struct { | ||
|
@@ -200,9 +206,13 @@ var defaultExclusions = []rule{ | |
excluded: false, | ||
}, | ||
{ | ||
val: filepath.Join("**", ".terraform", "**"), | ||
val: filepath.Join("**", ".terraform", "?**"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to actually discovery |
||
excluded: false, | ||
}, | ||
{ | ||
val: filepath.Join("**", ".terraform", "modules"), | ||
excluded: true, | ||
}, | ||
{ | ||
val: filepath.Join("**", ".terraform", "modules", "**"), | ||
excluded: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not terribly happy about having to include
**/*
in here, but it makes it possible to write ignorefiles like:and get only the
tf
,json
andhcl
files. Without this, the*
matches all directories and prevents recursion into anything that isn't explicitly allowed.