From 032fb6f70ae1f26d2febedb6c566e341aaa5e039 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 28 Jul 2017 19:55:41 +0200 Subject: syz-ci: send commits to dashboard Dashboard needs to know when bug fixing commits reach builders in order to fully close bugs. Send commits that dashboard is interested in to dashboard. --- pkg/git/git.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'pkg/git') diff --git a/pkg/git/git.go b/pkg/git/git.go index a3bdcec00..a239453f8 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -68,18 +68,29 @@ func clone(dir, repo, branch string) error { // HeadCommit returns hash of the HEAD commit of the current branch of git repository in dir. func HeadCommit(dir string) (string, error) { - output, err := osutil.RunCmd(timeout, dir, "git", "log", "--pretty=format:'%H'", "-n", "1") + output, err := osutil.RunCmd(timeout, dir, "git", "log", "--pretty=format:%H", "-n", "1") if err != nil { return "", err } if len(output) != 0 && output[len(output)-1] == '\n' { output = output[:len(output)-1] } - if len(output) != 0 && output[0] == '\'' && output[len(output)-1] == '\'' { - output = output[1 : len(output)-1] - } if len(output) != 40 { return "", fmt.Errorf("unexpected git log output, want commit hash: %q", output) } return string(output), nil } + +// ListRecentCommits returns list of commit titles for the last year starting from baseCommit. +func ListRecentCommits(dir, baseCommit string) ([]string, error) { + since := time.Now().Add(-time.Hour * 24 * 365).Format("01-02-2006") + // On upstream kernel this produces 3.5MB of output. + // Somewhat inefficient to collect whole output in a slice + // and then convert to string, but should be bearable. + output, err := osutil.RunCmd(timeout, dir, "git", "log", + "--pretty=format:%s", "--no-merges", "--since", since, baseCommit) + if err != nil { + return nil, err + } + return strings.Split(string(output), "\n"), nil +} -- cgit mrf-deployment