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

Method loadGitignorePatterns

internal/diff/git.go:233–247  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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