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

Function updatePullRequestReviewsREST

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

559// updatePullRequestReviewsREST uses the REST API to add/remove reviewers.
560// This is the legacy path for GHES compatibility.
561func 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
586type Surveyor interface {
587 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