mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-17 11:57:12 +03:00
Fix PR calc logic, remove bot accounts. (#17)
* Fix PR calc logic, remove bot accounts. * Fmt.
This commit is contained in:
parent
2ceadcd253
commit
04c9b37981
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user