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

Method loadGitignorePatterns

internal/diff/git.go:277–291  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

275
276// loadGitignorePatterns reads and parses .gitignore patterns from the repo root.
277func (p *Provider) loadGitignorePatterns() []string {
278 data, err := os.ReadFile(filepath.Join(p.repoDir, ".gitignore"))
279 if err != nil {
280 return nil
281 }
282 var patterns []string
283 for line := range strings.SplitSeq(string(data), "\n") {
284 line = strings.TrimSpace(line)
285 if line == "" || strings.HasPrefix(line, "#") {
286 continue
287 }
288 patterns = append(patterns, line)
289 }
290 return patterns
291}
292
293// isPathExcluded returns true when the given relative file path should be skipped
294// based on hardcoded dir rules or .gitignore patterns.

Callers 3

partitionDiffsMethod · 0.95
untrackedFilesListMethod · 0.95
LoadGitignorePatternsFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected