-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Fix bug when removing all PR reviewers #10975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the scenario where removing all reviewers on a PR was no-op by changing the guard logic to only skip when both reviewer ID slices are nil, and adds tests to cover non-interactive and interactive “remove all reviewers” flows.
- Relax guard clause in updatePullRequestReviews to allow empty slices to proceed with removal
- Added a non-interactive test for removing all reviewers
- Added an interactive test and extended testSurveyor to simulate removal of all reviewers
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
pkg/cmd/pr/edit/edit.go | Updated guard clause to only return early when both userIds and teamIds are nil |
pkg/cmd/pr/edit/edit_test.go | Added tests for non-interactive and interactive removal of all reviewers; extended testSurveyor |
Signed-off-by: Babak K. Shandiz <babakks@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reviewed this synchronously - LGTM
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | minor | `v2.72.0` -> `v2.73.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>cli/cli (cli/cli)</summary> ### [`v2.73.0`](https://github.com/cli/cli/releases/tag/v2.73.0): GitHub CLI 2.73.0 [Compare Source](cli/cli@v2.72.0...v2.73.0) ####Copilot Coding Agent Support You can now assign issues to GitHub Copilot directly from `gh`, just as you would assign them to a teammate. Use `gh issue edit <number> --add-assignee @​copilot` to assign the GitHub Copilot coding agent, and Copilot will work in the background to understand the issue, propose a solution, and open a pull request when it's ready for your review. If you run `gh issue edit` interactively, `Copilot (AI)` will be displayed as a potential assignee. This feature is available for GitHub Copilot Pro+ and Copilot Enterprise subscribers. For more details, refer to [the full changelog post for Copilot coding agent](https://github.blog/changelog/2025-05-19-github-copilot-coding-agent-in-public-preview/). #### What's Changed ##### ✨ Features - Copilot is assignable to issues and pull requests with `issue edit` and `pr edit` by [@​BagToad](https://github.com/BagToad) in cli/cli#10992 - `gh issue edit`: actors are assignable to issues by [@​BagToad](https://github.com/BagToad) in cli/cli#10960 - `gh pr edit`: Assign actors to pull requests by [@​BagToad](https://github.com/BagToad) in cli/cli#10984 - `issue edit`, `pr edit`: handle display names in interactive assignee editing by [@​BagToad](https://github.com/BagToad) in cli/cli#10990 - `issue edit`, `pr edit`: Support special non-interactive (flags) assignee name `@copilot` by [@​BagToad](https://github.com/BagToad) in cli/cli#10991 - \[gh issue/pr comment] Add support for last comment delete for issues and MRs by [@​sinansonmez](https://github.com/sinansonmez) in cli/cli#10596 - \[gh issue view] Expose `closedByPullRequestsReferences` JSON field by [@​iamazeem](https://github.com/iamazeem) in cli/cli#10941 - Accessible prompter always displays selection defaults in a format readable by a screen reader by [@​BagToad](https://github.com/BagToad) in cli/cli#10937 ##### 🐛 Fixes - Fix `StatusJSONResponse` usage by [@​babakks](https://github.com/babakks) in cli/cli#10810 - Fix panic on `gh pr view 0` by [@​nopcoder](https://github.com/nopcoder) in cli/cli#10729 - Fix flakey test for accessible prompter by [@​BagToad](https://github.com/BagToad) in cli/cli#10918 - Fix accessible prompter flaky tests by [@​babakks](https://github.com/babakks) in cli/cli#10977 - Handle missing archive URLs on release download by [@​williammartin](https://github.com/williammartin) in cli/cli#10947 - Fix bug when removing all MR reviewers by [@​babakks](https://github.com/babakks) in cli/cli#10975 ##### 📚 Docs & Chores - Feature detect v1 projects on pr view by [@​williammartin](https://github.com/williammartin) in cli/cli#10821 - Feature detect v1 projects on non-interactive pr create by [@​williammartin](https://github.com/williammartin) in cli/cli#10909 - Feature detect v1 projects on web mode pr create by [@​williammartin](https://github.com/williammartin) in cli/cli#10911 - Feature detect v1 projects on interactive `pr create` by [@​williammartin](https://github.com/williammartin) in cli/cli#10915 - Feature detect v1 projects on pr edit by [@​williammartin](https://github.com/williammartin) in cli/cli#10942 - Move predicate type filtering in `gh attestation verify` by [@​malancas](https://github.com/malancas) in cli/cli#10670 - Improve assertion for disabled echo mode by [@​babakks](https://github.com/babakks) in cli/cli#10927 #####
Dependencies - chore(deps): bump actions/attest-build-provenance from 2.2.2 to 2.3.0 by [@​dependabot](https://github.com/dependabot) in cli/cli#10886 - chore(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.6 to 2.0.7 by [@​dependabot](https://github.com/dependabot) in cli/cli#10869 #### What's Changed #### New Contributors - [@​sinansonmez](https://github.com/sinansonmez) made their first contribution in cli/cli#10596 - [@​nopcoder](https://github.com/nopcoder) made their first contribution in cli/cli#10729 **Full Changelog**: cli/cli@v2.72.0...v2.73.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xNS4wIiwidXBkYXRlZEluVmVyIjoiNDAuMTUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes #10958
This PR fixes a bug that prevented users from removing all reviewers assigned to a PR. The cause was a guard clause that aborted further processing if the slices of user IDs and team IDs were either
nil
or empty, when it should have only checked againstnil
.Acceptance Criteria
Removing user reviewer
Given I have a PR with only a user reviewer assigned to it
When I run
gh pr edit --remove-reviewer <user>
Then the PR is updated and has no reviewers
Works as expected; tested on the current PR.
Removing team reviewer
Given I have a PR with only a team reviewer assigned to it
When I run
gh pr edit --remove-reviewer <org>/<team>
Then the PR is updated and has no reviewers
Works as expected; tested on a test org with teams.
Removing both
Given I have a PR with both a user and a team reviewer assigned to it
When I run
gh pr edit --remove-reviewer <user>,<org>/<team>
Then the PR is updated and has no reviewers
Works as expected; tested on the current PR.