diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-07-28 19:55:41 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-07-28 20:14:24 +0200 |
| commit | 032fb6f70ae1f26d2febedb6c566e341aaa5e039 (patch) | |
| tree | d253590997e28bb09c64d3bd4fe6f27782e5d7fc /pkg/git | |
| parent | c579f3e6127a770c69716abec1c94c5033a073e7 (diff) | |
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.
Diffstat (limited to 'pkg/git')
| -rw-r--r-- | pkg/git/git.go | 19 |
1 files changed, 15 insertions, 4 deletions
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 +} |
