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

Method loadGitignorePatterns

internal/diff/git.go:239–253  ·  view source on GitHub ↗

loadGitignorePatterns reads and parses .gitignore patterns from the repo root.

()

Source from the content-addressed store, hash-verified

237
238// loadGitignorePatterns reads and parses .gitignore patterns from the repo root.
239func (p *Provider) loadGitignorePatterns() []string {
240 data, err := os.ReadFile(filepath.Join(p.repoDir, ".gitignore"))
241 if err != nil {
242 return nil
243 }
244 var patterns []string
245 for line := range strings.SplitSeq(string(data), "\n") {
246 line = strings.TrimSpace(line)
247 if line == "" || strings.HasPrefix(line, "#") {
248 continue
249 }
250 patterns = append(patterns, line)
251 }
252 return patterns
253}
254
255// isPathExcluded returns true when the given relative file path should be skipped
256// based on hardcoded dir rules or .gitignore patterns.

Callers 3

filterDiffsMethod · 0.95
untrackedFilesListMethod · 0.95
LoadGitignorePatternsFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected