SuggestedReviewerActorsForRepo fetches potential reviewers for a repository. Unlike SuggestedReviewerActors, this doesn't require an existing PR - used for gh pr create. It combines results from two sources using a cascading quota system: - repository collaborators (base quota: 5) - organization tea
(client *Client, repo ghrepo.Interface, query string)
| 554 | // unfilled quota from the previous source. Results are deduplicated. |
| 555 | // Returns the candidates, a MoreResults count, and an error. |
| 556 | func SuggestedReviewerActorsForRepo(client *Client, repo ghrepo.Interface, query string) ([]ReviewerCandidate, int, error) { |
| 557 | type responseData struct { |
| 558 | Viewer struct { |
| 559 | Login string |
| 560 | } |
| 561 | Repository struct { |
| 562 | // HACK: There's no repo-level API to check Copilot reviewer eligibility, |
| 563 | // so we piggyback on an open PR's suggestedReviewerActors to detect |
| 564 | // whether Copilot is available as a reviewer for this repository. |
| 565 | PullRequests struct { |
| 566 | Nodes []struct { |
| 567 | SuggestedActors struct { |
| 568 | Nodes []struct { |
| 569 | Reviewer struct { |
| 570 | TypeName string `graphql:"__typename"` |
| 571 | Bot struct { |
| 572 | Login string |
| 573 | } `graphql:"... on Bot"` |
| 574 | } |
| 575 | } |
| 576 | } `graphql:"suggestedReviewerActors(first: 10)"` |
| 577 | } |
| 578 | } `graphql:"pullRequests(first: 1, states: [OPEN])"` |
| 579 | Owner struct { |
| 580 | TypeName string `graphql:"__typename"` |
| 581 | Organization struct { |
| 582 | Teams struct { |
| 583 | Nodes []struct { |
| 584 | Slug string |
| 585 | } |
| 586 | } `graphql:"teams(first: 10, query: $query)"` |
| 587 | TeamsTotalCount struct { |
| 588 | TotalCount int |
| 589 | } `graphql:"teamsTotalCount: teams(first: 0)"` |
| 590 | } `graphql:"... on Organization"` |
| 591 | } |
| 592 | Collaborators struct { |
| 593 | Nodes []struct { |
| 594 | Login string |
| 595 | Name string |
| 596 | } |
| 597 | } `graphql:"collaborators(first: 10, query: $query)"` |
| 598 | CollaboratorsTotalCount struct { |
| 599 | TotalCount int |
| 600 | } `graphql:"collaboratorsTotalCount: collaborators(first: 0)"` |
| 601 | } `graphql:"repository(owner: $owner, name: $name)"` |
| 602 | } |
| 603 | |
| 604 | variables := map[string]interface{}{ |
| 605 | "query": githubv4.String(query), |
| 606 | "owner": githubv4.String(repo.RepoOwner()), |
| 607 | "name": githubv4.String(repo.RepoName()), |
| 608 | } |
| 609 | |
| 610 | var result responseData |
| 611 | err := client.Query(repo.RepoHost(), "SuggestedReviewerActorsForRepo", &result, variables) |
| 612 | if err != nil { |
| 613 | return nil, 0, err |