Skip to content

Conversation

andyfeller
Copy link
Member

@andyfeller andyfeller commented Jul 29, 2025

Fixes #11403

This PR 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.

Demo

Building this branch locally and testing in personal repositories:

cli/cli ‹andyfeller/11403-pr-team-reviewers›$ make clean && make
rm -rf bin share
go build -trimpath -ldflags "-X github.com/cli/cli/v2/internal/build.Date=2025-07-29 -X github.com/cli/cli/v2/internal/build.Version=v2.76.1-3-g8f20f0ab5 " -o bin/gh ./cmd/gh

cli/cli ‹andyfeller/11403-pr-team-reviewers›$ alias gh=$(realpath bin/gh)

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 metadata

tinyfists/gh-pr-test ‹cli-v2.76.1-pr-create-testing*›$ gh pr create
? Where should we push the 'cli-v2.76.1-pr-create-testing' branch? tinyfists/gh-pr-test
Working...

Creating pull request for cli-v2.76.1-pr-create-testing into main in tinyfists/gh-pr-test

? Title (required) Adding file to test with
? Choose a template Open a blank pull request
? Body <Received>
? What's next? Add metadata
? What would you like to add? Reviewers
Working...
? Reviewers  [Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
> [ ]  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/actions-monorepo-microservice-a
  [ ]  tinyfists/actions-monorepo-microservice-b
  [ ]  tinyfists/actions-monorepo-microservice-c
  [ ]  tinyfists/actions-monorepo-microservice-d
  [ ]  tinyfists/admin
  [ ]  tinyfists/away
  [ ]  tinyfists/gh-pr-reviewers
  [ ]  tinyfists/lgtm
  [ ]  tinyfists/lgtm-reviewers
  [ ]  tinyfists/lgtm-sensitive
  [ ]  tinyfists/lgtm-sensitive-reviewers
  [ ]  tinyfists/monks
  [ ]  tinyfists/mostly-away
  [ ]  tinyfists/omni-reviewers
  [ ]  tinyfists/partly-away
  [ ]  tinyfists/ps-delivery-engineers
  [ ]  tinyfists/pull-perms
  [ ]  tinyfists/readers
  [ ]  tinyfists/reposteam
  [ ]  tinyfists/reviewers
  [ ]  tinyfists/team-jessica
  [ ]  tinyfists/under_scores

Finishing the creation process:

$ gh pr create
? Where should we push the 'cli-v2.76.1-pr-create-testing' branch? tinyfists/gh-pr-test
Working...

Creating pull request for cli-v2.76.1-pr-create-testing into main in tinyfists/gh-pr-test

? Title (required) Adding file to test with
? Choose a template Open a blank pull request
? Body <Received>
? What's next? Add metadata
? What would you like to add? Reviewers
Working...
? Reviewers tinyfists/monks
? What's next? Submit
To https://github.com/tinyfists/gh-pr-test.git
   e1fff86..ec05429  HEAD -> cli-v2.76.1-pr-create-testing
branch 'cli-v2.76.1-pr-create-testing' set up to track 'origin/cli-v2.76.1-pr-create-testing'.
Working...
https://github.com/tinyfists/gh-pr-test/pull/11

In this case, the code owners were selected for reviewers due to repository ruleset but tinyfists/monks didn't have permission to the repo:

Screenshot 2025-07-29 at 6 37 21 PM

After fixing the repo permissions, this just provides opportunity to test the next fix...

gh pr edit --add-reviewer tab completion

$ gh pr edit 11 --add-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                                                 
Screenshot 2025-07-29 at 6 40 48 PM

And finally...

gh pr edit --remove-reviewer tab completion

$ gh pr edit 11 --remove-reviewer tinyfists/monks
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                        
Screenshot 2025-07-29 at 6 41 54 PM

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.
@Copilot Copilot AI review requested due to automatic review settings July 29, 2025 22:22
@andyfeller andyfeller requested a review from a team as a code owner July 29, 2025 22:22
@andyfeller andyfeller requested a review from babakks July 29, 2025 22:22
Copy link
Contributor

@Copilot Copilot AI left a 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.
Copy link
Member

@babakks babakks left a 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! 🍻

Comment on lines +1877 to +1882
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)
}
Copy link
Member

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:

Suggested change
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")

Copy link
Member Author

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",
Copy link
Member

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.

Copy link
Member Author

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 😞

Copy link
Member

@BagToad BagToad left a 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!

@andyfeller
Copy link
Member Author

Following up on govulncheck failure, github.com/go-chi/chi@v4.1.2+incompatible is a 2nd order, transitive dependency by way of github.com/sigstore/sigstore-go v1.1.0 and github.com/sigstore/rekor.

github.com/go-chi/chi@v5 has been out for a few years now, so there is a larger dependency vulnerability challenge here that we should work with @cli/package-security to work with the larger Sigstore community to fix perhaps? 🤷

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

@andyfeller andyfeller merged commit a2e23a2 into trunk Jul 30, 2025
10 of 11 checks passed
@andyfeller andyfeller deleted the andyfeller/11403-pr-team-reviewers branch July 30, 2025 21:05
Sameyboy88

This comment was marked as spam.

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jul 31, 2025
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 [@&#8203;andyfeller](https://github.com/andyfeller) in cli/cli#11407

##### 📚 Docs & Chores

- Delete obsolete comment about `gh-models` not respecting API rate-limit by [@&#8203;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-->
Pjrich1313

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PR Create lost the ability to ask review from teams
5 participants