@@ -10,7 +10,7 @@ import (
1010type PullRequestsPayload struct {
1111 ViewerCreated PullRequestAndTotalCount
1212 ReviewRequested PullRequestAndTotalCount
13- CurrentPRs [] PullRequest
13+ CurrentPR * PullRequest
1414}
1515
1616type PullRequestAndTotalCount struct {
@@ -262,13 +262,12 @@ func PullRequests(client *Client, repo ghrepo.Interface, currentPRNumber int, cu
262262 reviewRequested = append (reviewRequested , edge .Node )
263263 }
264264
265- var currentPRs []PullRequest
266- if resp .Repository .PullRequest != nil {
267- currentPRs = append (currentPRs , * resp .Repository .PullRequest )
268- } else {
265+ var currentPR = resp .Repository .PullRequest
266+ if currentPR == nil {
269267 for _ , edge := range resp .Repository .PullRequests .Edges {
270268 if edge .Node .HeadLabel () == currentPRHeadRef {
271- currentPRs = append (currentPRs , edge .Node )
269+ currentPR = & edge .Node
270+ break // Take the most recent PR for the current branch
272271 }
273272 }
274273 }
@@ -282,7 +281,7 @@ func PullRequests(client *Client, repo ghrepo.Interface, currentPRNumber int, cu
282281 PullRequests : reviewRequested ,
283282 TotalCount : resp .ReviewRequested .TotalCount ,
284283 },
285- CurrentPRs : currentPRs ,
284+ CurrentPR : currentPR ,
286285 }
287286
288287 return & payload , nil
@@ -507,6 +506,7 @@ func PullRequestList(client *Client, vars map[string]interface{}, limit int) (*P
507506 }
508507 }`
509508
509+ var check = make (map [int ]struct {})
510510 var prs []PullRequest
511511 pageLimit := min (limit , 100 )
512512 variables := map [string ]interface {}{}
@@ -583,7 +583,12 @@ loop:
583583 }
584584
585585 for _ , edge := range prData .Edges {
586+ if _ , exists := check [edge .Node .Number ]; exists {
587+ continue
588+ }
589+
586590 prs = append (prs , edge .Node )
591+ check [edge .Node .Number ] = struct {}{}
587592 if len (prs ) == limit {
588593 break loop
589594 }
0 commit comments