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

Method loadGitignorePatterns

internal/diff/git.go:232–246  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

230
231// loadGitignorePatterns reads and parses .gitignore patterns from the repo root.
232func (p *Provider) loadGitignorePatterns() []string {
233 data, err := os.ReadFile(filepath.Join(p.repoDir, ".gitignore"))
234 if err != nil {
235 return nil
236 }
237 var patterns []string
238 for line := range strings.SplitSeq(string(data), "\n") {
239 line = strings.TrimSpace(line)
240 if line == "" || strings.HasPrefix(line, "#") {
241 continue
242 }
243 patterns = append(patterns, line)
244 }
245 return patterns
246}
247
248// isPathExcluded returns true when the given relative file path should be skipped
249// 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