From 242b0eb219dbb269deacdae76de2f8b0b788ac40 Mon Sep 17 00:00:00 2001 From: Pedro Lopes Date: Tue, 28 Jul 2020 15:55:14 -0500 Subject: pkg: get and store Maintainers data Create a struct on pkg/vcs to store data of syzkaller email recipients and update its users. The struct contains default name, email, and a label to divide user into To and Cc when sending the emails. --- pkg/report/linux.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'pkg/report/linux.go') diff --git a/pkg/report/linux.go b/pkg/report/linux.go index de906adf9..85b62a89b 100644 --- a/pkg/report/linux.go +++ b/pkg/report/linux.go @@ -7,7 +7,6 @@ import ( "bufio" "bytes" "fmt" - "net/mail" "path/filepath" "regexp" "strconv" @@ -16,6 +15,7 @@ import ( "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/pkg/symbolizer" + "github.com/google/syzkaller/pkg/vcs" ) type linux struct { @@ -351,7 +351,7 @@ func (ctx *linux) Symbolize(rep *Report) error { if err != nil { return err } - rep.Maintainers = maintainers + rep.Recipients = maintainers } return nil } @@ -466,14 +466,14 @@ nextFile: return "" } -func (ctx *linux) getMaintainers(file string) ([]string, error) { +func (ctx *linux) getMaintainers(file string) (vcs.Recipients, error) { if ctx.kernelSrc == "" { return nil, nil } return GetLinuxMaintainers(ctx.kernelSrc, file) } -func GetLinuxMaintainers(kernelSrc, file string) ([]string, error) { +func GetLinuxMaintainers(kernelSrc, file string) (vcs.Recipients, error) { mtrs, err := getMaintainersImpl(kernelSrc, file, false) if err != nil { return nil, err @@ -487,9 +487,9 @@ func GetLinuxMaintainers(kernelSrc, file string) ([]string, error) { return mtrs, nil } -func getMaintainersImpl(kernelSrc, file string, blame bool) ([]string, error) { +func getMaintainersImpl(kernelSrc, file string, blame bool) (vcs.Recipients, error) { // See #1441 re --git-min-percent. - args := []string{"--no-n", "--no-rolestats", "--git-min-percent=15"} + args := []string{"--git-min-percent=15"} if blame { args = append(args, "--git-blame") } @@ -499,16 +499,7 @@ func getMaintainersImpl(kernelSrc, file string, blame bool) ([]string, error) { if err != nil { return nil, err } - lines := strings.Split(string(output), "\n") - var mtrs []string - for _, line := range lines { - addr, err := mail.ParseAddress(line) - if err != nil { - continue - } - mtrs = append(mtrs, addr.Address) - } - return mtrs, nil + return vcs.ParseMaintainersLinux(output), nil } func (ctx *linux) extractFiles(report []byte) []string { -- cgit mrf-deployment