MCPcopy Create free account
hub / github.com/alibaba/open-code-review / isPathExcluded

Method isPathExcluded

internal/diff/git.go:187–203  ·  view source on GitHub ↗

isPathExcluded returns true when the given relative file path should be skipped based on hardcoded dir rules or .gitignore patterns.

(relPath string, gitignorePatterns []string)

Source from the content-addressed store, hash-verified

185// isPathExcluded returns true when the given relative file path should be skipped
186// based on hardcoded dir rules or .gitignore patterns.
187func (p *Provider) isPathExcluded(relPath string, gitignorePatterns []string) bool {
188 // Hardcoded directory prefix checks
189 for _, prefix := range providerDirIgnoreDirs {
190 dirPart := strings.TrimSuffix(prefix, "/")
191 if relPath == dirPart || strings.HasPrefix(relPath, prefix) {
192 return true
193 }
194 }
195
196 // .gitignore pattern matching
197 for _, pat := range gitignorePatterns {
198 if matchGitignorePattern(relPath, pat) {
199 return true
200 }
201 }
202 return false
203}
204
205// matchGitignorePattern checks if relPath matches a single .gitignore pattern.
206func matchGitignorePattern(relPath, pat string) bool {

Callers 3

filterDiffsMethod · 0.95
untrackedFilesListMethod · 0.95
IsPathExcludedFunction · 0.95

Calls 1

matchGitignorePatternFunction · 0.85

Tested by

no test coverage detected