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

Function reviewerSearchFunc

pkg/cmd/pr/edit/edit.go:461–501  ·  view source on GitHub ↗

reviewerSearchFunc is intended to be an arg for MultiSelectWithSearch to return potential reviewer candidates (users, bots, and teams). It also updates the editable's metadata for later ID resolution.

(apiClient *api.Client, repo ghrepo.Interface, editable *shared.Editable, prID string)

Source from the content-addressed store, hash-verified

459// to return potential reviewer candidates (users, bots, and teams).
460// It also updates the editable's metadata for later ID resolution.
461func reviewerSearchFunc(apiClient *api.Client, repo ghrepo.Interface, editable *shared.Editable, prID string) func(string) prompter.MultiSelectSearchResult {
462 searchFunc := func(input string) prompter.MultiSelectSearchResult {
463 candidates, moreResults, err := api.SuggestedReviewerActors(
464 apiClient,
465 repo,
466 prID,
467 input)
468 if err != nil {
469 return prompter.MultiSelectSearchResult{
470 Keys: nil,
471 Labels: nil,
472 MoreResults: 0,
473 Err: err,
474 }
475 }
476
477 keys := make([]string, 0, len(candidates))
478 labels := make([]string, 0, len(candidates))
479
480 for _, c := range candidates {
481 keys = append(keys, c.Login())
482 labels = append(labels, c.DisplayName())
483
484 // Update the teams metadata in the editable struct
485 // so that updating the PR later can resolve the team ID.
486 if team, ok := c.(api.ReviewerTeam); ok {
487 editable.Metadata.Teams = append(editable.Metadata.Teams, api.OrgTeam{
488 ID: "", // ID not needed for REST API reviewer mutations
489 Slug: team.Slug(),
490 })
491 }
492 }
493 return prompter.MultiSelectSearchResult{
494 Keys: keys,
495 Labels: labels,
496 MoreResults: moreResults,
497 Err: nil,
498 }
499 }
500 return searchFunc
501}
502
503func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, id string, number int, editable shared.Editable) error {
504 var wg errgroup.Group

Callers 1

editRunFunction · 0.85

Calls 4

SuggestedReviewerActorsFunction · 0.92
SlugMethod · 0.80
LoginMethod · 0.65
DisplayNameMethod · 0.65

Tested by

no test coverage detected