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