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

Method loadGitignorePatterns

internal/diff/git.go:169–183  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

167
168// loadGitignorePatterns reads and parses .gitignore patterns from the repo root.
169func (p *Provider) loadGitignorePatterns() []string {
170 data, err := os.ReadFile(filepath.Join(p.repoDir, ".gitignore"))
171 if err != nil {
172 return nil
173 }
174 var patterns []string
175 for line := range strings.SplitSeq(string(data), "\n") {
176 line = strings.TrimSpace(line)
177 if line == "" || strings.HasPrefix(line, "#") {
178 continue
179 }
180 patterns = append(patterns, line)
181 }
182 return patterns
183}
184
185// isPathExcluded returns true when the given relative file path should be skipped
186// 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