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)
| 369 | // to return potential reviewer candidates (users, bots, and teams). |
| 370 | // It also updates the editable's metadata for later ID resolution. |
| 371 | func reviewerSearchFunc(apiClient *api.Client, repo ghrepo.Interface, editable *shared.Editable, prID string) func(string) prompter.MultiSelectSearchResult { |
| 372 | searchFunc := func(input string) prompter.MultiSelectSearchResult { |
| 373 | candidates, moreResults, err := api.SuggestedReviewerActors( |
| 374 | apiClient, |
| 375 | repo, |
| 376 | prID, |
| 377 | input) |
| 378 | if err != nil { |
| 379 | return prompter.MultiSelectSearchResult{ |
| 380 | Keys: nil, |
| 381 | Labels: nil, |
| 382 | MoreResults: 0, |
| 383 | Err: err, |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | keys := make([]string, 0, len(candidates)) |
| 388 | labels := make([]string, 0, len(candidates)) |
| 389 | |
| 390 | for _, c := range candidates { |
| 391 | keys = append(keys, c.Login()) |
| 392 | labels = append(labels, c.DisplayName()) |
| 393 | |
| 394 | // Update the teams metadata in the editable struct |
| 395 | // so that updating the PR later can resolve the team ID. |
| 396 | if team, ok := c.(api.ReviewerTeam); ok { |
| 397 | editable.Metadata.Teams = append(editable.Metadata.Teams, api.OrgTeam{ |
| 398 | ID: "", // ID not needed for REST API reviewer mutations |
| 399 | Slug: team.Slug(), |
| 400 | }) |
| 401 | } |
| 402 | } |
| 403 | return prompter.MultiSelectSearchResult{ |
| 404 | Keys: keys, |
| 405 | Labels: labels, |
| 406 | MoreResults: moreResults, |
| 407 | Err: nil, |
| 408 | } |
| 409 | } |
| 410 | return searchFunc |
| 411 | } |
| 412 | |
| 413 | func updatePullRequest(httpClient *http.Client, repo ghrepo.Interface, id string, number int, editable shared.Editable) error { |
| 414 | var wg errgroup.Group |
no test coverage detected