aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-06-22 13:21:33 +0200
committerAndrey Konovalov <andreyknvl@google.com>2017-06-26 21:23:14 +0200
commit3ad6daa90a66d74de8a52185d7ecae04f1d69b87 (patch)
tree4b0fb1c395b37d167cc5478ba2deaf16f608879b /pkg
parentf6267bfc3686037be7bd0c2b394dcdd0dc150258 (diff)
report: add get maintainers function
Diffstat (limited to 'pkg')
-rw-r--r--pkg/git/git.go3
-rw-r--r--pkg/report/guilty.go41
2 files changed, 42 insertions, 2 deletions
diff --git a/pkg/git/git.go b/pkg/git/git.go
index 5c91c6040..29ebcbadc 100644
--- a/pkg/git/git.go
+++ b/pkg/git/git.go
@@ -36,7 +36,7 @@ func Poll(dir, repo, branch string) (string, error) {
return "", err
}
}
- if _, err := osutil.RunCmd(timeout, dir, "git", "fetch", "--no-tags", "--depth", "1"); err != nil {
+ if _, err := osutil.RunCmd(timeout, dir, "git", "fetch", "--no-tags"); err != nil {
// Something else is wrong, re-clone.
if err := clone(dir, repo, branch); err != nil {
return "", err
@@ -58,7 +58,6 @@ func clone(dir, repo, branch string) error {
args := []string{
"clone",
repo,
- "--depth", "1",
"--single-branch",
"--branch", branch,
dir,
diff --git a/pkg/report/guilty.go b/pkg/report/guilty.go
index 087d2f275..272f63063 100644
--- a/pkg/report/guilty.go
+++ b/pkg/report/guilty.go
@@ -4,8 +4,12 @@
package report
import (
+ "net/mail"
"regexp"
"strings"
+ "time"
+
+ "github.com/google/syzkaller/pkg/osutil"
)
var (
@@ -52,3 +56,40 @@ nextFile:
}
return ""
}
+
+func getMaintainersImpl(linux, file string, blame bool) ([]string, error) {
+ // ./scripts/get_maintainer.pl is a Linux kernel script.
+ args := []string{"--no-n", "--no-rolestats"}
+ if blame {
+ args = append(args, "--git-blame")
+ }
+ args = append(args, file)
+ output, err := osutil.RunCmd(time.Minute, linux, "./scripts/get_maintainer.pl", args...)
+ 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
+}
+
+func GetMaintainers(linux, file string) ([]string, error) {
+ mtrs, err := getMaintainersImpl(linux, file, false)
+ if err != nil {
+ return nil, err
+ }
+ if len(mtrs) <= 1 {
+ mtrs, err = getMaintainersImpl(linux, file, true)
+ if err != nil {
+ return nil, err
+ }
+ }
+ return mtrs, nil
+}