isPathExcluded returns true when the given relative file path should be skipped based on hardcoded dir rules or .gitignore patterns. Patterns are resolved the way git resolves them: in file order, with the LAST matching pattern deciding, and a leading "!" inverting that pattern's verdict. Order mat
(relPath string, gitignorePatterns []string)
| 300 | // correct under last-match-wins. Treating negations as unmatchable made every |
| 301 | // file in such a repository look excluded, so a review silently covered nothing. |
| 302 | func (p *Provider) isPathExcluded(relPath string, gitignorePatterns []string) bool { |
| 303 | if isProviderDirExcluded(relPath) { |
| 304 | return true |
| 305 | } |
| 306 | |
| 307 | excluded := false |
| 308 | for _, pat := range gitignorePatterns { |
| 309 | body, negated := strings.CutPrefix(pat, "!") |
| 310 | if body == "" { |
| 311 | continue |
| 312 | } |
| 313 | |
| 314 | // Directory-only patterns (trailing "/") apply to directories, never to |
| 315 | // files. Git uses a negated one such as `!*/` to keep descending into |
| 316 | // subdirectories, not to re-admit the files inside them — honouring it |
| 317 | // here would readmit everything below the root. |
| 318 | if negated && strings.HasSuffix(body, "/") { |
| 319 | continue |
| 320 | } |
| 321 | |
| 322 | if matchGitignoreBody(relPath, body) { |
| 323 | excluded = !negated |
| 324 | } |
| 325 | } |
| 326 | return excluded |
| 327 | } |
| 328 | |
| 329 | // isProviderDirExcluded reports whether relPath matches the provider's |
| 330 | // unconditional directory blocklist. A .gitignore negation cannot re-admit |
no test coverage detected