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

Function updatePullRequestReviewsREST

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

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

Callers 1

updatePullRequestReviewsFunction · 0.85

Calls 4

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

Tested by

no test coverage detected