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

Function updatePullRequestReviews

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

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