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

Function reviewerSearchFunc

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

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