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

Method partitionDiffs

internal/diff/git.go:432–455  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

430// In workspace mode, ignored untracked files are already filtered out.
431// Applying .gitignore here would incorrectly drop tracked changes.
432func (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

Callers 1

GetDiffSetMethod · 0.95

Calls 3

loadGitignorePatternsMethod · 0.95
isPathExcludedMethod · 0.95
isProviderDirExcludedFunction · 0.85

Tested by

no test coverage detected