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)
| 459 | // to return potential reviewer candidates (users, bots, and teams). |
| 460 | // It also updates the editable's metadata for later ID resolution. |
| 461 | func 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 | |
| 503 | func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, id string, number int, editable shared.Editable) error { |
| 504 | var wg errgroup.Group |
no test coverage detected