MCPcopy Create free account
hub / github.com/cli/cli / updatePullRequestReviewsREST

Function updatePullRequestReviewsREST

pkg/cmd/pr/edit/edit.go:566–589  ·  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

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