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

Function reviewerSearchFunc

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

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