(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable)
| 424 | } |
| 425 | |
| 426 | func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable) error { |
| 427 | if !editable.Reviewers.Edited { |
| 428 | return nil |
| 429 | } |
| 430 | |
| 431 | client := api.NewClientFromHTTP(httpClient) |
| 432 | |
| 433 | // Rebuild the Value slice from non-interactive flag input. |
| 434 | if len(editable.Reviewers.Add) != 0 || len(editable.Reviewers.Remove) != 0 { |
| 435 | add := editable.Reviewers.Add |
| 436 | remove := editable.Reviewers.Remove |
| 437 | |
| 438 | // Replace @copilot with the Copilot reviewer login (only on github.com). |
| 439 | // Also use DefaultLogins (not Default display names) for computing the set. |
| 440 | var defaultLogins []string |
| 441 | // TODO ApiActorsSupported |
| 442 | if editable.ApiActorsSupported { |
| 443 | copilotReplacer := shared.NewCopilotReviewerReplacer() |
| 444 | add = copilotReplacer.ReplaceSlice(add) |
| 445 | remove = copilotReplacer.ReplaceSlice(remove) |
| 446 | defaultLogins = editable.Reviewers.DefaultLogins |
| 447 | } else { |
| 448 | // On GHES, Default already contains logins (no display name distinction) |
| 449 | defaultLogins = editable.Reviewers.Default |
| 450 | } |
| 451 | |
| 452 | s := set.NewStringSet() |
| 453 | s.AddValues(add) |
| 454 | s.AddValues(defaultLogins) |
| 455 | s.RemoveValues(remove) |
| 456 | editable.Reviewers.Value = s.ToSlice() |
| 457 | } |
| 458 | |
| 459 | // On github.com, use the new GraphQL mutation which supports bots. |
| 460 | // On GHES, fall back to REST API. |
| 461 | // TODO ApiActorsSupported |
| 462 | if editable.ApiActorsSupported { |
| 463 | return updatePullRequestReviewsGraphQL(client, repo, prID, editable) |
| 464 | } |
| 465 | return updatePullRequestReviewsREST(client, repo, number, editable) |
| 466 | } |
| 467 | |
| 468 | // updatePullRequestReviewsGraphQL uses the RequestReviewsByLogin mutation. |
| 469 | // This mutation replaces the entire reviewer set (union: false). |
no test coverage detected