From 76280ee7ce2ebc67e633381930ef8409046aba99 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 15 Dec 2020 15:09:49 +0100 Subject: pkg/vcs: reorder code Recipients is not the most importnat part of the vcs interface, move it from the very top closer to the bottom. --- pkg/vcs/vcs.go | 100 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'pkg/vcs') diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index e698867a4..d86e15f62 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -19,56 +19,6 @@ import ( "github.com/google/syzkaller/sys/targets" ) -type RecipientType int - -const ( - To RecipientType = iota - Cc -) - -func (t RecipientType) String() string { - return [...]string{"To", "Cc"}[t] -} - -type RecipientInfo struct { - Address mail.Address - Type RecipientType -} - -type Recipients []RecipientInfo - -func (r Recipients) GetEmails(filter RecipientType) []string { - emails := []string{} - for _, user := range r { - if user.Type == filter { - emails = append(emails, user.Address.Address) - } - } - sort.Strings(emails) - return emails -} - -func NewRecipients(emails []string, t RecipientType) Recipients { - r := Recipients{} - for _, e := range emails { - r = append(r, RecipientInfo{mail.Address{Address: e}, t}) - } - sort.Sort(r) - return r -} - -func (r Recipients) Len() int { return len(r) } -func (r Recipients) Less(i, j int) bool { return r[i].Address.Address < r[j].Address.Address } -func (r Recipients) Swap(i, j int) { r[i], r[j] = r[j], r[i] } - -func (r Recipients) ToDash() dashapi.Recipients { - d := dashapi.Recipients{} - for _, user := range r { - d = append(d, dashapi.RecipientInfo{Address: user.Address, Type: dashapi.RecipientType(user.Type)}) - } - return d -} - type Repo interface { // Poll checkouts the specified repository/branch. // This involves fetching/resetting/cloning as necessary to recover from all possible problems. @@ -148,6 +98,56 @@ type Commit struct { CommitDate time.Time } +type RecipientType int + +const ( + To RecipientType = iota + Cc +) + +func (t RecipientType) String() string { + return [...]string{"To", "Cc"}[t] +} + +type RecipientInfo struct { + Address mail.Address + Type RecipientType +} + +type Recipients []RecipientInfo + +func (r Recipients) GetEmails(filter RecipientType) []string { + emails := []string{} + for _, user := range r { + if user.Type == filter { + emails = append(emails, user.Address.Address) + } + } + sort.Strings(emails) + return emails +} + +func NewRecipients(emails []string, t RecipientType) Recipients { + r := Recipients{} + for _, e := range emails { + r = append(r, RecipientInfo{mail.Address{Address: e}, t}) + } + sort.Sort(r) + return r +} + +func (r Recipients) Len() int { return len(r) } +func (r Recipients) Less(i, j int) bool { return r[i].Address.Address < r[j].Address.Address } +func (r Recipients) Swap(i, j int) { r[i], r[j] = r[j], r[i] } + +func (r Recipients) ToDash() dashapi.Recipients { + d := dashapi.Recipients{} + for _, user := range r { + d = append(d, dashapi.RecipientInfo{Address: user.Address, Type: dashapi.RecipientType(user.Type)}) + } + return d +} + type BisectResult int const ( -- cgit mrf-deployment