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

Function RequestReviewsByLogin

api/queries_pr_review.go:358–399  ·  view source on GitHub ↗

RequestReviewsByLogin sets requested reviewers on a pull request using the GraphQL mutation. This mutation replaces existing reviewers with the provided set unless union is true. Only available on github.com, not GHES. Bot logins should be passed without the [bot] suffix; it is appended automaticall

(client *Client, repo ghrepo.Interface, prID string, userLogins, botLogins, teamSlugs []string, union bool)

Source from the content-addressed store, hash-verified

356// Team slugs must be in the format "org/team-slug".
357// When union is false (replace mode), passing empty slices will remove all reviewers.
358func RequestReviewsByLogin(client *Client, repo ghrepo.Interface, prID string, userLogins, botLogins, teamSlugs []string, union bool) error {
359 // In union mode (additive), nothing to do if all lists are empty.
360 // In replace mode, we may still need to call the mutation to clear reviewers.
361 if union && len(userLogins) == 0 && len(botLogins) == 0 && len(teamSlugs) == 0 {
362 return nil
363 }
364
365 var mutation struct {
366 RequestReviewsByLogin struct {
367 ClientMutationId string `graphql:"clientMutationId"`
368 } `graphql:"requestReviewsByLogin(input: $input)"`
369 }
370
371 type RequestReviewsByLoginInput struct {
372 PullRequestID githubv4.ID `json:"pullRequestId"`
373 UserLogins *[]githubv4.String `json:"userLogins,omitempty"`
374 BotLogins *[]githubv4.String `json:"botLogins,omitempty"`
375 TeamSlugs *[]githubv4.String `json:"teamSlugs,omitempty"`
376 Union githubv4.Boolean `json:"union"`
377 }
378
379 input := RequestReviewsByLoginInput{
380 PullRequestID: githubv4.ID(prID),
381 Union: githubv4.Boolean(union),
382 }
383
384 userLoginValues := toGitHubV4Strings(userLogins, "")
385 input.UserLogins = &userLoginValues
386
387 // Bot logins require the [bot] suffix for the mutation
388 botLoginValues := toGitHubV4Strings(botLogins, "[bot]")
389 input.BotLogins = &botLoginValues
390
391 teamSlugValues := toGitHubV4Strings(teamSlugs, "")
392 input.TeamSlugs = &teamSlugValues
393
394 variables := map[string]any{
395 "input": input,
396 }
397
398 return client.Mutate(repo.RepoHost(), "RequestReviewsByLogin", &mutation, variables)
399}
400
401// SuggestedReviewerActors fetches suggested reviewers for a pull request.
402// It combines results from three sources using a cascading quota system:

Callers 2

CreatePullRequestFunction · 0.85

Calls 4

toGitHubV4StringsFunction · 0.85
IDMethod · 0.65
MutateMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected