MCPcopy
hub / github.com/cli/cli / updatePullRequestReviews

Function updatePullRequestReviews

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

424}
425
426func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable) error {
427 if !editable.Reviewers.Edited {
428 return nil
429 }
430
431 client := api.NewClientFromHTTP(httpClient)
432
433 // Rebuild the Value slice from non-interactive flag input.
434 if len(editable.Reviewers.Add) != 0 || len(editable.Reviewers.Remove) != 0 {
435 add := editable.Reviewers.Add
436 remove := editable.Reviewers.Remove
437
438 // Replace @copilot with the Copilot reviewer login (only on github.com).
439 // Also use DefaultLogins (not Default display names) for computing the set.
440 var defaultLogins []string
441 // TODO ApiActorsSupported
442 if editable.ApiActorsSupported {
443 copilotReplacer := shared.NewCopilotReviewerReplacer()
444 add = copilotReplacer.ReplaceSlice(add)
445 remove = copilotReplacer.ReplaceSlice(remove)
446 defaultLogins = editable.Reviewers.DefaultLogins
447 } else {
448 // On GHES, Default already contains logins (no display name distinction)
449 defaultLogins = editable.Reviewers.Default
450 }
451
452 s := set.NewStringSet()
453 s.AddValues(add)
454 s.AddValues(defaultLogins)
455 s.RemoveValues(remove)
456 editable.Reviewers.Value = s.ToSlice()
457 }
458
459 // On github.com, use the new GraphQL mutation which supports bots.
460 // On GHES, fall back to REST API.
461 // TODO ApiActorsSupported
462 if editable.ApiActorsSupported {
463 return updatePullRequestReviewsGraphQL(client, repo, prID, editable)
464 }
465 return updatePullRequestReviewsREST(client, repo, number, editable)
466}
467
468// updatePullRequestReviewsGraphQL uses the RequestReviewsByLogin mutation.
469// 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