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

Method loadGitignorePatterns

internal/diff/git.go:230–244  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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