MCPcopy Create free account
hub / github.com/JordanCoin/codemap / shouldIncludeFile

Function shouldIncludeFile

scanner/walker.go:176–202  ·  view source on GitHub ↗

shouldIncludeFile checks if a file passes the only/exclude filters

(relPath string, ext string, only []string, exclude []string)

Source from the content-addressed store, hash-verified

174
175// shouldIncludeFile checks if a file passes the only/exclude filters
176func shouldIncludeFile(relPath string, ext string, only []string, exclude []string) bool {
177 // If --only specified, file extension must be in the list
178 if len(only) > 0 {
179 extNoDot := strings.TrimPrefix(ext, ".")
180 found := false
181 for _, o := range only {
182 o = strings.TrimPrefix(strings.TrimSpace(o), ".")
183 if strings.EqualFold(extNoDot, o) {
184 found = true
185 break
186 }
187 }
188 if !found {
189 return false
190 }
191 }
192
193 // If --exclude specified, check against each pattern
194 for _, pattern := range exclude {
195 pattern = strings.TrimSpace(pattern)
196 if pattern != "" && matchesPattern(relPath, pattern) {
197 return false
198 }
199 }
200
201 return true
202}
203
204// LoadGitignore loads .gitignore from root if it exists
205// Deprecated: Use NewGitIgnoreCache for nested gitignore support

Callers 2

TestShouldIncludeFileFunction · 0.85
ScanFilesFunction · 0.85

Calls 1

matchesPatternFunction · 0.85

Tested by 1

TestShouldIncludeFileFunction · 0.68