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

Function updatePullRequestReviews

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

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