Fix PR calc logic, remove bot accounts. (#17)

* Fix PR calc logic, remove bot accounts.

* Fmt.
This commit is contained in:
Abhishek Arya 2020-10-16 16:11:07 -07:00 committed by GitHub
parent 2ceadcd253
commit 04c9b37981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,8 @@
package checks
import (
"strings"
"github.com/dlorenc/scorecard/checker"
"github.com/google/go-github/v32/github"
)
@ -18,14 +20,28 @@ func PullRequests(c checker.Checker) checker.CheckResult {
total := 0
totalWithPrs := 0
for _, commit := range commits {
isBot := false
committer := commit.GetCommitter().GetLogin()
for _, substring := range []string{"bot", "gardener"} {
if strings.Contains(committer, substring) {
isBot = true
break
}
}
if isBot {
c.Logf("skip commit from bot account: %s", committer)
continue
}
prs, _, err := c.Client.PullRequests.ListPullRequestsWithCommit(c.Ctx, c.Owner, c.Repo, commit.GetSHA(), &github.PullRequestListOptions{})
if err != nil {
return checker.RetryResult(err)
}
total++
if len(prs) > 0 {
c.Logf("found PRs, example: #%v", prs[0].GetNumber())
totalWithPrs++
}
}
return checker.ProportionalResult(totalWithPrs, total, .9)
return checker.ProportionalResult(totalWithPrs, total, .75)
}

View File

@ -26,7 +26,7 @@ func SignedTags(c checker.Checker) checker.CheckResult {
return checker.RetryResult(err)
}
if gt.GetVerification().GetVerified() {
c.Logf("signed tag found: %s", t.GetCommit().GetSHA())
c.Logf("signed tag found: %s, commit: %s", *t.Name, t.GetCommit().GetSHA())
totalSigned++
}
if totalReleases > tagLookBack {