Select module files with ancestor boundary lookups
This commit is contained in:
@@ -95,7 +95,7 @@ func (tree *CandidateTree) InputEntries() []git.TreeEntry {
|
||||
}
|
||||
|
||||
func selectInputEntries(entries []git.TreeEntry, byPath map[string]int, modulePath string, sharedFiles []string) ([]git.TreeEntry, error) {
|
||||
boundaries := make([]string, 0)
|
||||
boundaries := make(map[string]struct{})
|
||||
for _, entry := range entries {
|
||||
moduleRelative, ok := relativeToModule(entry.Path, modulePath)
|
||||
if !ok || moduleRelative == "go.mod" || path.Base(moduleRelative) != "go.mod" {
|
||||
@@ -104,7 +104,7 @@ func selectInputEntries(entries []git.TreeEntry, byPath map[string]int, modulePa
|
||||
if insideVendor(moduleRelative) {
|
||||
continue
|
||||
}
|
||||
boundaries = append(boundaries, path.Dir(entry.Path))
|
||||
boundaries[path.Dir(entry.Path)] = struct{}{}
|
||||
}
|
||||
selected := make(map[string]git.TreeEntry)
|
||||
for _, entry := range entries {
|
||||
@@ -113,8 +113,8 @@ func selectInputEntries(entries []git.TreeEntry, byPath map[string]int, modulePa
|
||||
continue
|
||||
}
|
||||
excluded := false
|
||||
for _, boundary := range boundaries {
|
||||
if entry.Path == boundary || strings.HasPrefix(entry.Path, boundary+"/") {
|
||||
for ancestor := entry.Path; ancestor != "." && ancestor != modulePath; ancestor = path.Dir(ancestor) {
|
||||
if _, isBoundary := boundaries[ancestor]; isBoundary {
|
||||
excluded = true
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user