@@ -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
1414func 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