MCPcopy
hub / github.com/cli/cli / RemovePullRequestReviews

Function RemovePullRequestReviews

api/queries_pr_review.go:310–339  ·  view source on GitHub ↗

RemovePullRequestReviews removes requested reviewers from a pull request using the REST API. Team identifiers can be in "org/slug" format.

(client *Client, repo ghrepo.Interface, prNumber int, users, teams []string)

Source from the content-addressed store, hash-verified

308// RemovePullRequestReviews removes requested reviewers from a pull request using the REST API.
309// Team identifiers can be in "org/slug" format.
310func RemovePullRequestReviews(client *Client, repo ghrepo.Interface, prNumber int, users, teams []string) error {
311 if len(users) == 0 && len(teams) == 0 {
312 return nil
313 }
314
315 // The API requires empty arrays instead of null values
316 if users == nil {
317 users = []string{}
318 }
319
320 path := fmt.Sprintf(
321 "repos/%s/%s/pulls/%d/requested_reviewers",
322 url.PathEscape(repo.RepoOwner()),
323 url.PathEscape(repo.RepoName()),
324 prNumber,
325 )
326 body := struct {
327 Reviewers []string `json:"reviewers"`
328 TeamReviewers []string `json:"team_reviewers"`
329 }{
330 Reviewers: users,
331 TeamReviewers: extractTeamSlugs(teams),
332 }
333 buf := &bytes.Buffer{}
334 if err := json.NewEncoder(buf).Encode(body); err != nil {
335 return err
336 }
337 // The endpoint responds with the updated pull request object; we don't need it here.
338 return client.REST(repo.RepoHost(), "DELETE", path, buf, nil)
339}
340
341// RequestReviewsByLogin sets requested reviewers on a pull request using the GraphQL mutation.
342// This mutation replaces existing reviewers with the provided set unless union is true.

Callers 1

Calls 5

extractTeamSlugsFunction · 0.85
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected