-
Notifications
You must be signed in to change notification settings - Fork 7k
Include org teams for PR reviewers #11407
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
This commit enhances the following scenarios to include organization teams as pull request reviewers: 1. Interactive `gh pr create` during additional metadata 2. Tab completing `gh pr create --reviewer` 3. Tab completing `gh pr edit --add-reviewer` 4. Tab completing `gh pr edit --remove-reviewer` Additionally, a new `gh pr create` test case for ensuring that teams show up within interactive prompts has been added.
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 enhances the GitHub CLI to include organization teams as reviewers when creating and editing pull requests. The change addresses issue #11403 by ensuring teams are fetched and available for selection in interactive prompts and tab completion scenarios.
- Enable team reviewers to be fetched when creating PRs interactively
- Include team reviewers in tab completion for
--reviewer
and--add-reviewer
/--remove-reviewer
flags - Add comprehensive test coverage for interactive team reviewer selection
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
pkg/cmd/pr/shared/survey.go | Enables fetching team reviewers when "Reviewers" metadata is selected |
pkg/cmd/pr/shared/completion.go | Updates completion logic to include team reviewers alongside individual reviewers |
pkg/cmd/pr/create/create_test.go | Adds test case verifying team reviewers appear in interactive prompts and updates existing test names |
This commit moves the `gh pr create` tab completion test closer to the logic rather than the commands that use it. This should ensure that any command or flag that lists reviewers will present teams and users as expected.
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.
LGTM! Thanks for the quick fix! 🍻
if v, ok := inputs["assigneeIds"]; ok { | ||
t.Errorf("did not expect assigneeIds: %v", v) | ||
} | ||
if v, ok := inputs["userIds"]; ok { | ||
t.Errorf("did not expect userIds: %v", v) | ||
} |
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.
For consistency you can use require
/assert
:
if v, ok := inputs["assigneeIds"]; ok { | |
t.Errorf("did not expect assigneeIds: %v", v) | |
} | |
if v, ok := inputs["userIds"]; ok { | |
t.Errorf("did not expect userIds: %v", v) | |
} | |
assert.NotContains(t, inputs, "assigneeIds") | |
assert.NotContains(t, inputs, "userIds") |
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.
I appreciate that suggestion 🙇 I based this test on an existing gh pr create
test and was reusing its logic, so we might need to update multiple tests 🤔
}, | ||
}, | ||
{ | ||
name: "when users are available but teams aren't, users are listed", |
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.
This is just to improve coverage, so feel free to skip.
What do you think about another test case to simulate the Could not resolve to an Organization
API error? It can be added here, or rather to api/queries_repo_test.go
.
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.
That is a solid suggestion 🤔
I'd like to follow this PR up with that improvement so we can ship this regression fix while not forgetting about this. I thought I had this exact response documented in my notes but I can't find it 😞
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.
Looks good to me, thanks!
Following up on govulncheck failure,
I'm going to proceed with merging these changes for a hotfix while following up on an improved test for GraphQL resolve error mentioned by @babakks |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [cli/cli](https://github.com/cli/cli) | patch | `v2.76.1` -> `v2.76.2` | 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.76.2`](https://github.com/cli/cli/releases/tag/v2.76.2): GitHub CLI 2.76.2 [Compare Source](cli/cli@v2.76.1...v2.76.2) #### `gh pr create` regression fix This release fixes a regression introduced in `v2.76.1` where organization teams were not present in prompts for pull request reviewers. This caused problems in multiple commands: - Interactive `gh pr create` could not select teams when adding pull request reviewers - Tab completions with `gh pr create --reviewer` flag did not present a list of organization teams - Tab completions with `gh pr edit --add-reviewer` flag did not present a list of organization teams - Tab completions with `gh pr edit --remove-reviewer` flag did not present a list of organization teams For more information, see cli/cli#11403 #### What's Changed ##### 🐛 Fixes - Include org teams for MR reviewers by [@​andyfeller](https://github.com/andyfeller) in cli/cli#11407 ##### 📚 Docs & Chores - Delete obsolete comment about `gh-models` not respecting API rate-limit by [@​babakks](https://github.com/babakks) in cli/cli#11398 **Full Changelog**: cli/cli@v2.76.1...v2.76.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, 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:eyJjcmVhdGVkSW5WZXIiOiI0MS40NS4wIiwidXBkYXRlZEluVmVyIjoiNDEuNDUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes #11403
This PR enhances the following scenarios to include organization teams as pull request reviewers:
gh pr create
during additional metadatagh pr create --reviewer
gh pr edit --add-reviewer
gh pr edit --remove-reviewer
Additionally, a new
gh pr create
test case for ensuring that teams show up within interactive prompts has been added.Demo
Building this branch locally and testing in personal repositories:
gh pr create --reviewer
tab completion‹cli-v2.76.1-pr-create-testing*›$ gh pr create --reviewer amenocal amenocal -- Alejandro Menocal apdarr -- Alex Darr david-wiggs -- David Wiggs decyjphr -- Yadhav Jayaraman enyil -- Enyil Valle evgenyrahman -- Evgeny Rahman garnertb -- Tyler Garner JaredEgolf -- Jared Egolf jefeish -- Jürgen Efeish jonwicksy -- Jon Wicks katiem0 -- Katie May kevfoste -- Kevin Foster polivebranch -- Payton Oliveri ssulei7 -- Sully vila89 -- Victoria Lam tinyfists/actions-monorepo tinyfists/lgtm tinyfists/ps-delivery-engineers tinyfists/actions-monorepo-microservice-a tinyfists/lgtm-reviewers tinyfists/pull-perms tinyfists/actions-monorepo-microservice-b tinyfists/lgtm-sensitive tinyfists/readers tinyfists/actions-monorepo-microservice-c tinyfists/lgtm-sensitive-reviewers tinyfists/reposteam tinyfists/actions-monorepo-microservice-d tinyfists/monks tinyfists/reviewers tinyfists/admin tinyfists/mostly-away tinyfists/team-jessica tinyfists/away tinyfists/omni-reviewers tinyfists/under_scores tinyfists/gh-pr-reviewers tinyfists/partly-away
gh pr create
interactive reviewers metadataFinishing the creation process:
In this case, the code owners were selected for reviewers due to repository ruleset but
tinyfists/monks
didn't have permission to the repo:After fixing the repo permissions, this just provides opportunity to test the next fix...
gh pr edit --add-reviewer
tab completionAnd finally...
gh pr edit --remove-reviewer
tab completion