Select module files with ancestor boundary lookups

This commit is contained in:
2026-10-10 14:29:27 +00:00
parent 8552f92ddb
commit 8112a001d2
4 changed files with 56 additions and 6 deletions

View File

@@ -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
}