partitionDiffs keeps diffs filtered by built-in directory rules available for reporting while preserving the review input as the Included slice. In workspace mode, ignored untracked files are already filtered out. Applying .gitignore here would incorrectly drop tracked changes.
(diffs []model.Diff)
| 430 | // In workspace mode, ignored untracked files are already filtered out. |
| 431 | // Applying .gitignore here would incorrectly drop tracked changes. |
| 432 | func (p *Provider) partitionDiffs(diffs []model.Diff) DiffSet { |
| 433 | var patterns []string |
| 434 | honorGitignore := p.mode != ModeWorkspace |
| 435 | if honorGitignore { |
| 436 | patterns = p.loadGitignorePatterns() |
| 437 | } |
| 438 | result := DiffSet{ |
| 439 | Included: make([]model.Diff, 0, len(diffs)), |
| 440 | Excluded: make([]model.Diff, 0), |
| 441 | } |
| 442 | for _, d := range diffs { |
| 443 | path := d.NewPath |
| 444 | if path == "/dev/null" { |
| 445 | path = d.OldPath |
| 446 | } |
| 447 | if isProviderDirExcluded(path) { |
| 448 | result.excludedAt = append(result.excludedAt, len(result.Included)+len(result.Excluded)) |
| 449 | result.Excluded = append(result.Excluded, d) |
| 450 | } else if !honorGitignore || !p.isPathExcluded(path, patterns) { |
| 451 | result.Included = append(result.Included, d) |
| 452 | } |
| 453 | } |
| 454 | return result |
| 455 | } |
| 456 | |
| 457 | // ---- Internal helpers ---- |
| 458 |
no test coverage detected