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

Function partitionDiffs

internal/diff/git.go:443–461  ·  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, patterns GitignorePatterns)

Source from the content-addressed store, hash-verified

441// In workspace mode, ignored untracked files are already filtered out.
442// Applying .gitignore here would incorrectly drop tracked changes.
443func partitionDiffs(diffs []model.Diff, patterns GitignorePatterns) DiffSet {
444 result := DiffSet{
445 Included: make([]model.Diff, 0, len(diffs)),
446 Excluded: make([]model.Diff, 0),
447 }
448 for _, d := range diffs {
449 path := d.NewPath
450 if path == "/dev/null" {
451 path = d.OldPath
452 }
453 if isProviderDirExcluded(path) {
454 result.excludedAt = append(result.excludedAt, len(result.Included)+len(result.Excluded))
455 result.Excluded = append(result.Excluded, d)
456 } else if !patterns.Matches(path) {
457 result.Included = append(result.Included, d)
458 }
459 }
460 return result
461}
462
463// ---- Internal helpers ----
464

Callers 1

GetDiffSetMethod · 0.85

Calls 2

isProviderDirExcludedFunction · 0.85
MatchesMethod · 0.80

Tested by

no test coverage detected