From 1df6c94250b7558c1016ec24dadb97c447213e16 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 8 Sep 2023 11:36:03 +0200 Subject: pkg/subsystem: do not reuse customly grouped records If a record was specified in a custom subsystem list, do not consider it while grouping records by mailing list. --- pkg/subsystem/linux/subsystems.go | 21 ++++++++++++++++----- pkg/subsystem/linux/subsystems_test.go | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) (limited to 'pkg/subsystem/linux') diff --git a/pkg/subsystem/linux/subsystems.go b/pkg/subsystem/linux/subsystems.go index 1d1d84ed2..38473c901 100644 --- a/pkg/subsystem/linux/subsystems.go +++ b/pkg/subsystem/linux/subsystems.go @@ -29,12 +29,11 @@ func listFromRepoInner(root fs.FS, rules *customRules) ([]*subsystem.Subsystem, rawRecords: records, extraRules: rules, } - list := ctx.groupByList() extraList, err := ctx.groupByRules() if err != nil { return nil, err } - list = append(list, extraList...) + list := append(ctx.groupByList(), extraList...) matrix, err := BuildCoincidenceMatrix(root, list, dropPatterns) if err != nil { return nil, err @@ -108,19 +107,31 @@ func (ctx *linuxCtx) groupByRules() ([]*subsystem.Subsystem, error) { for _, item := range ctx.rawRecords { perName[item.name] = item } - ret := []*subsystem.Subsystem{} + var ret []*subsystem.Subsystem + exclude := map[*maintainersRecord]struct{}{} for name, recordNames := range ctx.extraRules.extraSubsystems { matching := []*maintainersRecord{} for _, recordName := range recordNames { - if perName[recordName] == nil { + record := perName[recordName] + if record == nil { return nil, fmt.Errorf("MAINTAINERS record not found: %#v", recordName) } - matching = append(matching, perName[recordName]) + exclude[record] = struct{}{} + matching = append(matching, record) } s := mergeRawRecords(matching, "") s.Name = name ret = append(ret, s) } + // Exclude rawRecords from further consideration. + var newRecords []*maintainersRecord + for _, record := range ctx.rawRecords { + if _, ok := exclude[record]; ok { + continue + } + newRecords = append(newRecords, record) + } + ctx.rawRecords = newRecords return ret, nil } diff --git a/pkg/subsystem/linux/subsystems_test.go b/pkg/subsystem/linux/subsystems_test.go index f60f6d70f..7e6869161 100644 --- a/pkg/subsystem/linux/subsystems_test.go +++ b/pkg/subsystem/linux/subsystems_test.go @@ -27,9 +27,10 @@ func TestGroupLinuxSubsystems(t *testing.T) { } expected := []*subsystem.Subsystem{ { - Name: "fs", - Lists: []string{"linux-fsdevel@vger.kernel.org"}, - Maintainers: []string{"email_vfs@email.com"}, + Name: "fs", + Lists: []string{"linux-fsdevel@vger.kernel.org"}, + // Two different subsystems point to linux-fsdevel@vger.kernel.org, so + // we do not include maintainers. }, { Name: "ext4", @@ -73,7 +74,15 @@ func TestCustomCallRules(t *testing.T) { assert.Contains(t, subsystems, &subsystem.Subsystem{ Name: "udf", Maintainers: []string{"email_udf@email.com"}, + Lists: []string{"linux-fsdevel@vger.kernel.org"}, }) + // Now that udf is excluded, it becomes possible to generate a maintainer list for vfs. + assert.Contains(t, subsystems, &subsystem.Subsystem{ + Name: "fs", + Lists: []string{"linux-fsdevel@vger.kernel.org"}, + Maintainers: []string{"email_vfs@email.com"}, + }) + expectCalls := map[string][]string{ "ext4": {"syz_mount_image$ext4"}, "tmpfs": {"syz_mount_image$tmpfs"}, @@ -275,6 +284,7 @@ F: mm/shmem* UDF FILESYSTEM M: email_udf +L: linux-fsdevel@vger.kernel.org S: Maintained F: Documentation/filesystems/udf.rst F: fs/udf/ -- cgit mrf-deployment