aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/subsystem')
-rw-r--r--pkg/subsystem/entities.go13
-rw-r--r--pkg/subsystem/entities_test.go18
2 files changed, 31 insertions, 0 deletions
diff --git a/pkg/subsystem/entities.go b/pkg/subsystem/entities.go
index 05032e6c2..1f7456e84 100644
--- a/pkg/subsystem/entities.go
+++ b/pkg/subsystem/entities.go
@@ -31,6 +31,19 @@ func (subsystem *Subsystem) ReachableParents() map[*Subsystem]struct{} {
return ret
}
+// Emails returns the list of emails related to the subsystem.
+func (subsystem *Subsystem) Emails() []string {
+ ret := []string{}
+ // For the subsystem itself, we take both lists and maintainers.
+ ret = append(ret, subsystem.Lists...)
+ ret = append(ret, subsystem.Maintainers...)
+ // For its parent subsystems, we only take lists.
+ for parent := range subsystem.ReachableParents() {
+ ret = append(ret, parent.Lists...)
+ }
+ return ret
+}
+
// PathRule describes the part of the directory tree belonging to a single subsystem.
type PathRule struct {
IncludeRegexp string
diff --git a/pkg/subsystem/entities_test.go b/pkg/subsystem/entities_test.go
index df65dbd5a..58166b91b 100644
--- a/pkg/subsystem/entities_test.go
+++ b/pkg/subsystem/entities_test.go
@@ -21,3 +21,21 @@ func TestReachableParents(t *testing.T) {
}
assert.ElementsMatch(t, retParents, []*Subsystem{parentA, parentB, parentParent})
}
+
+func TestSubsystemEmails(t *testing.T) {
+ parentParent := &Subsystem{Lists: []string{"a@list.com"}, Maintainers: []string{"a@person.com"}}
+ parent1 := &Subsystem{Lists: []string{"b@list.com"}, Maintainers: []string{"b@person.com"}}
+ parent2 := &Subsystem{
+ Lists: []string{"c@list.com"},
+ Maintainers: []string{"c@person.com"},
+ Parents: []*Subsystem{parentParent},
+ }
+ subsystem := &Subsystem{
+ Lists: []string{"d@list.com"},
+ Maintainers: []string{"d@person.com"},
+ Parents: []*Subsystem{parent1, parent2},
+ }
+ assert.ElementsMatch(t, subsystem.Emails(), []string{
+ "a@list.com", "b@list.com", "c@list.com", "d@list.com", "d@person.com",
+ })
+}