MCPcopy Index your code
hub / github.com/cli/cli / updatePullRequestReviewsREST

Function updatePullRequestReviewsREST

pkg/cmd/pr/edit/edit.go:477–500  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

475// updatePullRequestReviewsREST uses the REST API to add/remove reviewers.
476// This is the legacy path for GHES compatibility.
477func 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
502type Surveyor interface {
503 FieldsToEdit(*shared.Editable) error

Callers 1

updatePullRequestReviewsFunction · 0.85

Calls 5

AddPullRequestReviewsFunction · 0.92
RemovePullRequestReviewsFunction · 0.92
partitionReviewersByTypeFunction · 0.85
ContainsMethod · 0.80
WaitMethod · 0.65

Tested by

no test coverage detected