MCPcopy Create free account
hub / github.com/bufbuild/buf / shouldExcludeFile

Function shouldExcludeFile

private/bufpkg/bufimage/util.go:205–220  ·  view source on GitHub ↗

shouldExcludeFile takes the map of all the matching target paths and the map of all the matching exclude paths for an image file and takes the union of the two sets of matches to return a bool on whether or not we should exclude the file from the image.

(
	fileMatchingPathMap map[string]struct{},
	fileMatchingExcludePathMap map[string]struct{},
)

Source from the content-addressed store, hash-verified

203// exclude paths for an image file and takes the union of the two sets of matches to return
204// a bool on whether or not we should exclude the file from the image.
205func shouldExcludeFile(
206 fileMatchingPathMap map[string]struct{},
207 fileMatchingExcludePathMap map[string]struct{},
208) bool {
209 for fileMatchingPath := range fileMatchingPathMap {
210 for fileMatchingExcludePath := range fileMatchingExcludePathMap {
211 if normalpath.EqualsOrContainsPath(fileMatchingPath, fileMatchingExcludePath, normalpath.Relative) {
212 delete(fileMatchingPathMap, fileMatchingPath)
213 continue
214 }
215 }
216 }
217 // If there are no potential paths remaining,
218 // then the file should be excluded.
219 return len(fileMatchingPathMap) == 0
220}
221
222func getImageWithImports(
223 image Image,

Callers 1

imageWithOnlyPathsFunction · 0.85

Calls 1

EqualsOrContainsPathFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…