updatePullRequestReviewsREST uses the REST API to add/remove reviewers. This is the legacy path for GHES compatibility.
(client *api.Client, repo ghrepo.Interface, number int, editable shared.Editable)
| 559 | // updatePullRequestReviewsREST uses the REST API to add/remove reviewers. |
| 560 | // This is the legacy path for GHES compatibility. |
| 561 | func updatePullRequestReviewsREST(client *api.Client, repo ghrepo.Interface, number int, editable shared.Editable) error { |
| 562 | addUsers, addBots, addTeams := partitionReviewersByType(editable.Reviewers.Value) |
| 563 | // REST API doesn't distinguish bots from users, so we need to combine them. |
| 564 | allAddUsers := append(addUsers, addBots...) |
| 565 | |
| 566 | // Reviewers in Default but not in Value have been removed interactively. |
| 567 | var toRemove []string |
| 568 | for _, r := range editable.Reviewers.Default { |
| 569 | if !slices.Contains(editable.Reviewers.Value, r) { |
| 570 | toRemove = append(toRemove, r) |
| 571 | } |
| 572 | } |
| 573 | removeUsers, removeBots, removeTeams := partitionReviewersByType(toRemove) |
| 574 | allRemoveUsers := append(removeUsers, removeBots...) |
| 575 | |
| 576 | wg := errgroup.Group{} |
| 577 | wg.Go(func() error { |
| 578 | return api.AddPullRequestReviews(client, repo, number, allAddUsers, addTeams) |
| 579 | }) |
| 580 | wg.Go(func() error { |
| 581 | return api.RemovePullRequestReviews(client, repo, number, allRemoveUsers, removeTeams) |
| 582 | }) |
| 583 | return wg.Wait() |
| 584 | } |
| 585 | |
| 586 | type Surveyor interface { |
| 587 | FieldsToEdit(*shared.Editable) error |
no test coverage detected