(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable)
| 514 | } |
| 515 | |
| 516 | func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, prID string, number int, editable shared.Editable) error { |
| 517 | if !editable.Reviewers.Edited { |
| 518 | return nil |
| 519 | } |
| 520 | |
| 521 | client := api.NewClientFromHTTP(httpClient) |
| 522 | |
| 523 | // Rebuild the Value slice from non-interactive flag input. |
| 524 | if len(editable.Reviewers.Add) != 0 || len(editable.Reviewers.Remove) != 0 { |
| 525 | add := editable.Reviewers.Add |
| 526 | remove := editable.Reviewers.Remove |
| 527 | |
| 528 | // Replace @copilot with the Copilot reviewer login (only on github.com). |
| 529 | // Also use DefaultLogins (not Default display names) for computing the set. |
| 530 | var defaultLogins []string |
| 531 | // TODO ApiActorsSupported |
| 532 | if editable.ApiActorsSupported { |
| 533 | copilotReplacer := shared.NewCopilotReviewerReplacer() |
| 534 | add = copilotReplacer.ReplaceSlice(add) |
| 535 | remove = copilotReplacer.ReplaceSlice(remove) |
| 536 | defaultLogins = editable.Reviewers.DefaultLogins |
| 537 | } else { |
| 538 | // On GHES, Default already contains logins (no display name distinction) |
| 539 | defaultLogins = editable.Reviewers.Default |
| 540 | } |
| 541 | |
| 542 | s := set.NewStringSet() |
| 543 | s.AddValues(add) |
| 544 | s.AddValues(defaultLogins) |
| 545 | s.RemoveValues(remove) |
| 546 | editable.Reviewers.Value = s.ToSlice() |
| 547 | } |
| 548 | |
| 549 | // On github.com, use the new GraphQL mutation which supports bots. |
| 550 | // On GHES, fall back to REST API. |
| 551 | // TODO ApiActorsSupported |
| 552 | if editable.ApiActorsSupported { |
| 553 | return updatePullRequestReviewsGraphQL(client, repo, prID, editable) |
| 554 | } |
| 555 | return updatePullRequestReviewsREST(client, repo, number, editable) |
| 556 | } |
| 557 | |
| 558 | // updatePullRequestReviewsGraphQL uses the RequestReviewsByLogin mutation. |
| 559 | // This mutation replaces the entire reviewer set (union: false). |
no test coverage detected