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

Function updatePullRequestReviews

pkg/cmd/pr/edit/edit.go:509–549  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable)

Source from the content-addressed store, hash-verified

507}
508
509func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable) error {
510 if !editable.Reviewers.Edited {
511 return nil
512 }
513
514 client := api.NewClientFromHTTP(httpClient)
515
516 // Rebuild the Value slice from non-interactive flag input.
517 if len(editable.Reviewers.Add) != 0 || len(editable.Reviewers.Remove) != 0 {
518 add := editable.Reviewers.Add
519 remove := editable.Reviewers.Remove
520
521 // Replace @copilot with the Copilot reviewer login (only on github.com).
522 // Also use DefaultLogins (not Default display names) for computing the set.
523 var defaultLogins []string
524 // TODO ApiActorsSupported
525 if editable.ApiActorsSupported {
526 copilotReplacer := shared.NewCopilotReviewerReplacer()
527 add = copilotReplacer.ReplaceSlice(add)
528 remove = copilotReplacer.ReplaceSlice(remove)
529 defaultLogins = editable.Reviewers.DefaultLogins
530 } else {
531 // On GHES, Default already contains logins (no display name distinction)
532 defaultLogins = editable.Reviewers.Default
533 }
534
535 s := set.NewStringSet()
536 s.AddValues(add)
537 s.AddValues(defaultLogins)
538 s.RemoveValues(remove)
539 editable.Reviewers.Value = s.ToSlice()
540 }
541
542 // On github.com, use the new GraphQL mutation which supports bots.
543 // On GHES, fall back to REST API.
544 // TODO ApiActorsSupported
545 if editable.ApiActorsSupported {
546 return updatePullRequestReviewsGraphQL(client, repo, prID, editable)
547 }
548 return updatePullRequestReviewsREST(client, repo, number, editable)
549}
550
551// updatePullRequestReviewsGraphQL uses the RequestReviewsByLogin mutation.
552// This mutation replaces the entire reviewer set (union: false).

Callers 1

updatePullRequestFunction · 0.85

Calls 9

NewClientFromHTTPFunction · 0.92
NewStringSetFunction · 0.92
AddValuesMethod · 0.80
RemoveValuesMethod · 0.80
ToSliceMethod · 0.65
ReplaceSliceMethod · 0.45

Tested by

no test coverage detected