MCPcopy Create free account
hub / github.com/cli/cli / RemovePullRequestReviews

Function RemovePullRequestReviews

api/queries_pr_review.go:316–350  ·  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

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

Callers 1

Calls 7

JoinPathFunction · 0.92
extractTeamSlugsFunction · 0.85
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected