Skip to content

Commit c36689e

Browse files
authored
Merge pull request #51 from Chia-Network/find-all-PRs
Find all PRs
2 parents 6c29552 + 0fd0e89 commit c36689e

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

internal/github/checkUnsigned.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func CheckUnsignedCommits(ctx context.Context, githubClient *github.Client, cfg
3636
}
3737
owner, repo := parts[0], parts[1]
3838

39-
communityPRs, err := FindCommunityPRs(cfg, teamMembers, githubClient, owner, repo, fullRepo.MinimumNumber)
39+
communityPRs, err := FindAllPRs(cfg, teamMembers, githubClient, owner, repo, fullRepo.MinimumNumber)
4040
if err != nil {
4141
return nil, err
4242
}
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ import (
1010
"github.com/chia-network/github-bot/internal/config"
1111
)
1212

13-
// FindCommunityPRs obtains PRs based on provided filters
13+
// FindCommunityPRs obtains PRs based on provided filters for community members
1414
func FindCommunityPRs(cfg *config.Config, teamMembers map[string]bool, githubClient *github.Client, owner string, repo string, minimumNumber int) ([]*github.PullRequest, error) {
15+
return findPRs(cfg, teamMembers, githubClient, owner, repo, minimumNumber, true)
16+
}
17+
18+
// FindAllPRs obtains all PRs for the repository
19+
func FindAllPRs(cfg *config.Config, teamMembers map[string]bool, githubClient *github.Client, owner string, repo string, minimumNumber int) ([]*github.PullRequest, error) {
20+
return findPRs(cfg, teamMembers, githubClient, owner, repo, minimumNumber, false)
21+
}
22+
23+
// findPRs handles fetching and filtering PRs based on community or all contributors
24+
func findPRs(cfg *config.Config, teamMembers map[string]bool, githubClient *github.Client, owner string, repo string, minimumNumber int, filterCommunity bool) ([]*github.PullRequest, error) {
1525
var finalPRs []*github.PullRequest
1626
opts := &github.PullRequestListOptions{
1727
State: "open",
@@ -36,19 +46,23 @@ func FindCommunityPRs(cfg *config.Config, teamMembers map[string]bool, githubCli
3646
if *pullRequest.Draft {
3747
continue
3848
}
49+
3950
user := *pullRequest.User.Login
40-
if !teamMembers[user] && !cfg.SkipUsersMap[user] {
41-
slogs.Logr.Info("Pull request meets criteria, adding to final list", "PR", pullRequest.GetHTMLURL(), "user", user)
42-
finalPRs = append(finalPRs, pullRequest)
43-
} else {
51+
// If filtering community PRs, skip PRs by internal team members and users in SkipUsersMap
52+
if filterCommunity && (teamMembers[user] || cfg.SkipUsersMap[user]) {
4453
slogs.Logr.Info("Pull request does not meet criteria, skipping", "PR", pullRequest.GetHTMLURL(), "user", user)
54+
continue
4555
}
56+
57+
slogs.Logr.Info("Pull request meets criteria, adding to final list", "PR", pullRequest.GetHTMLURL(), "user", user)
58+
finalPRs = append(finalPRs, pullRequest)
4659
}
4760

4861
if resp.NextPage == 0 {
4962
break // Exit the loop if there are no more pages
5063
}
5164
opts.Page = resp.NextPage // Set next page number
5265
}
66+
5367
return finalPRs, nil
5468
}

0 commit comments

Comments
 (0)