@@ -23,21 +23,34 @@ func (r Repository) findMatchingPullRequest(ctx context.Context, options GitHubO
23
23
if err != nil {
24
24
return nil , fmt .Errorf ("failed to create github client: %w" , err )
25
25
}
26
- prs , _ , err := client .PullRequests .List (ctx , r .Owner , r .Name , & github.PullRequestListOptions {
27
- Base : options .PullRequest .BaseBranch ,
28
- })
29
- if err != nil {
30
- return nil , fmt .Errorf ("failed to list opened Pull Requests for repository %s: %w" , r .FullName (), err )
31
- }
32
26
33
- for _ , pr := range prs {
34
- if prHasLabels (pr , options .PullRequest .Labels ) {
35
- logrus .WithFields (logrus.Fields {
36
- "repository" : r .FullName (),
37
- "labels" : options .PullRequest .Labels ,
38
- "pull-request" : pr .GetHTMLURL (),
39
- }).Info ("Found existing Pull Request" )
40
- return pr , nil
27
+ page := 1
28
+ for {
29
+ prs , resp , err := client .PullRequests .List (ctx , r .Owner , r .Name , & github.PullRequestListOptions {
30
+ Base : options .PullRequest .BaseBranch ,
31
+ ListOptions : github.ListOptions {
32
+ Page : page ,
33
+ PerPage : 100 ,
34
+ },
35
+ })
36
+ if err != nil {
37
+ return nil , fmt .Errorf ("failed to list opened Pull Requests for repository %s: %w" , r .FullName (), err )
38
+ }
39
+
40
+ for _ , pr := range prs {
41
+ if prHasLabels (pr , options .PullRequest .Labels ) {
42
+ logrus .WithFields (logrus.Fields {
43
+ "repository" : r .FullName (),
44
+ "labels" : options .PullRequest .Labels ,
45
+ "pull-request" : pr .GetHTMLURL (),
46
+ }).Info ("Found existing Pull Request" )
47
+ return pr , nil
48
+ }
49
+ }
50
+
51
+ page = resp .NextPage
52
+ if resp .NextPage == 0 {
53
+ break
41
54
}
42
55
}
43
56
0 commit comments