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)
| 475 | // updatePullRequestReviewsREST uses the REST API to add/remove reviewers. |
| 476 | // This is the legacy path for GHES compatibility. |
| 477 | func updatePullRequestReviewsREST(client *api.Client, repo ghrepo.Interface, number int, editable shared.Editable) error { |
| 478 | addUsers, addBots, addTeams := partitionReviewersByType(editable.Reviewers.Value) |
| 479 | // REST API doesn't distinguish bots from users, so we need to combine them. |
| 480 | allAddUsers := append(addUsers, addBots...) |
| 481 | |
| 482 | // Reviewers in Default but not in Value have been removed interactively. |
| 483 | var toRemove []string |
| 484 | for _, r := range editable.Reviewers.Default { |
| 485 | if !slices.Contains(editable.Reviewers.Value, r) { |
| 486 | toRemove = append(toRemove, r) |
| 487 | } |
| 488 | } |
| 489 | removeUsers, removeBots, removeTeams := partitionReviewersByType(toRemove) |
| 490 | allRemoveUsers := append(removeUsers, removeBots...) |
| 491 | |
| 492 | wg := errgroup.Group{} |
| 493 | wg.Go(func() error { |
| 494 | return api.AddPullRequestReviews(client, repo, number, allAddUsers, addTeams) |
| 495 | }) |
| 496 | wg.Go(func() error { |
| 497 | return api.RemovePullRequestReviews(client, repo, number, allRemoveUsers, removeTeams) |
| 498 | }) |
| 499 | return wg.Wait() |
| 500 | } |
| 501 | |
| 502 | type Surveyor interface { |
| 503 | FieldsToEdit(*shared.Editable) error |
no test coverage detected