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

Method loadGitignorePatterns

internal/diff/git.go:171–185  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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