From 8d41190df0b6184bac7d8b34765fc84395f27cf4 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 18 Jan 2023 16:22:07 +0100 Subject: pkg/subsystem/linux: keep one list for list-merged groups Otherwise we can get too many mailing lists at the same time. --- pkg/subsystem/linux/subsystems.go | 19 +++++++++++-------- pkg/subsystem/linux/subsystems_test.go | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'pkg/subsystem') diff --git a/pkg/subsystem/linux/subsystems.go b/pkg/subsystem/linux/subsystems.go index 9d9688758..8d8716bf9 100644 --- a/pkg/subsystem/linux/subsystems.go +++ b/pkg/subsystem/linux/subsystems.go @@ -79,7 +79,7 @@ func (ctx *linuxCtx) getSubsystems() ([]*entity.Subsystem, error) { ret := []*entity.Subsystem{} for _, raw := range ctx.groupByList() { s := &entity.Subsystem{} - mergeRawRecords(s, raw.records) + raw.mergeRawRecords(s) ret = append(ret, s) } if err := setSubsystemNames(ret); err != nil { @@ -98,7 +98,7 @@ func (ctx *linuxCtx) applyExtraRules(list []*entity.Subsystem) { } } -func mergeRawRecords(subsystem *entity.Subsystem, records []*maintainersRecord) { +func (candidate *subsystemCandidate) mergeRawRecords(subsystem *entity.Subsystem) { unique := func(list []string) []string { m := make(map[string]struct{}) for _, s := range list { @@ -111,19 +111,22 @@ func mergeRawRecords(subsystem *entity.Subsystem, records []*maintainersRecord) sort.Strings(ret) return ret } - var lists, maintainers []string - for _, record := range records { + var maintainers []string + for _, record := range candidate.records { rule := record.ToPathRule() if !rule.IsEmpty() { subsystem.PathRules = append(subsystem.PathRules, rule) } - lists = append(lists, record.lists...) maintainers = append(maintainers, record.maintainers...) } - subsystem.Lists = unique(lists) - // But there's a risk that we collect too many unrelated maintainers, so + if candidate.commonEmail != "" { + // For list-grouped subsystems, we risk merging just too many lists. + // Keep the list short in this case. + subsystem.Lists = []string{candidate.commonEmail} + } + // There's a risk that we collect too many unrelated maintainers, so // let's only merge them if there are no lists. - if len(records) <= 1 { + if len(candidate.records) <= 1 { subsystem.Maintainers = unique(maintainers) } } diff --git a/pkg/subsystem/linux/subsystems_test.go b/pkg/subsystem/linux/subsystems_test.go index b4f0818ff..09d835e3f 100644 --- a/pkg/subsystem/linux/subsystems_test.go +++ b/pkg/subsystem/linux/subsystems_test.go @@ -75,7 +75,7 @@ func TestLinuxSubsystemPaths(t *testing.T) { // For the list of subsystems, see TestLinuxSubsystemsList. // Here we rely on the same ones. repo := prepareTestLinuxRepo(t, []byte(testMaintainers)) - subsystems, err := listFromRepoInner(repo, testRules) + subsystems, err := listFromRepoInner(repo, nil) if err != nil { t.Fatal(err) } @@ -106,6 +106,7 @@ func TestLinuxSubsystemPaths(t *testing.T) { list: []string{"kernel", "mm"}, }, { + // Shmem has no mailing list. path: `mm/shmem.c`, list: []string{"kernel", "mm"}, }, -- cgit mrf-deployment