Commit graph

50 commits

Author SHA1 Message Date
Kynan Ware
3c00ffdade refactor(pr shared): consolidate ActorAssignees and ActorReviewers into ApiActorsSupported
The CLI had two per-entity flags (ActorAssignees on EditableAssignees and
IssueMetadataState, ActorReviewers on IssueMetadataState) threaded through
different layers of the stack to distinguish github.com from GHES. Both
flags were always set from the same source (issueFeatures.ActorIsAssignable)
and never had different values, but they were carried independently on
different structs. This led to a confusing asymmetry where:

- EditableAssignees had ActorAssignees but EditableReviewers had nothing
- The PR edit flow piggybacked on editable.Assignees.ActorAssignees to
  make reviewer mutation decisions, which was misleading
- RepoMetadataInput only had ActorAssignees with no reviewer equivalent

This commit replaces all per-entity flags with a single ApiActorsSupported
bool hoisted to the shared level on Editable, IssueMetadataState, and
RepoMetadataInput. Both assignees and reviewers now key off the same signal.

Every branch site is marked with // TODO ApiActorsSupported so we can grep
for cleanup sites when GHES eventually supports the actor-based mutations
(replaceActorsForAssignable, requestReviewsByLogin).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-24 21:04:41 -06:00
Kynan Ware
33783748f3 review: address code review feedback
- Fix tests: assert logins (not display names) in actorLogins
- Remove dead ReplaceActorsForAssignableByID (no callers)
- Extract shared AssigneeSearchFunc to pkg/cmd/pr/shared/editable.go
- Remove duplicate assigneeSearchFunc from pr/edit and issue/edit

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-23 17:36:52 -06:00
Kynan Ware
b3cfe7454c refactor(pr edit, issue edit): use login-based assignee mutation for flag flows
When ActorAssignees is true (github.com), the --add-assignee and
--remove-assignee flag flows now pass logins directly to
ReplaceActorsForAssignableByLogin instead of bulk fetching all
assignable actors and resolving logins to node IDs.

Changes:
- New AssigneeLogins() method on Editable that computes the final
  login set (defaults + add - remove) without ID resolution
- UpdateIssue: call AssigneeLogins + ByLogin when ActorAssignees is true
- EditableOptionsFetch: skip assignee bulk fetch for flag flows on
  github.com (only fetch on GHES where ID resolution is needed)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-23 15:33:37 -06:00
Kynan Ware
d643d5386e fix(pr edit): send empty slices to clear reviewers in replace mode
Always send explicit lists for userLogins, botLogins, and teamSlugs
in RequestReviewsByLogin mutation, even when empty. Previously, empty
slices were omitted due to omitempty JSON behavior and len > 0 checks,
which prevented clearing all reviewers when using replace mode.

Empty slices are harmless no-ops in union mode, so we now send them
unconditionally for simpler logic.

Add test to verify the mutation receives empty slices when all
reviewers are removed.
2026-01-29 10:37:11 -07:00
Kynan Ware
738b82ddab Add CCR and reviewer MultiSelectWithSearch
Enables Copilot to be requested as a pull request reviewer, supporting both interactive and non-interactive flows. Introduces new reviewer search functionality, updates reviewer partitioning to distinguish users, bots, and teams, and adds a GraphQL mutation for reviewer management on github.com. Updates help text, tests, and internal APIs to support Copilot reviewer login and display names, while maintaining compatibility with GitHub Enterprise Server.
2026-01-27 23:11:51 -07:00
Kynan Ware
a8053d6e93 Remove redundant comment in editRun test 2026-01-26 14:56:50 -07:00
Kynan Ware
fb031b2b43 Add test for legacy assignee flow on GHES
Introduces a test case to verify that the interactive edit flow on GitHub Enterprise Server uses the legacy assignee selection without search, ensuring correct behavior when editing pull request assignees.
2026-01-26 13:48:23 -07:00
Kynan Ware
07dfdf97ae Update edit tests
Updated test mocks and logic to consistently use lowercase 'monalisa' for login names and display names for user assignees. Improved handling of dynamic assignee fetching in interactive flows by relying on searchFunc and metadata population, and clarified logic in FetchOptions to fetch assignees only when necessary. These changes ensure more accurate simulation of interactive assignment and better test coverage for actor assignee features.
2026-01-26 13:29:22 -07:00
Kynan Ware
31398fe765 Add test for non-interactive projects v1 unsupported
Introduces a test case to ensure that when editing pull requests non-interactively and projects v1 is unsupported, v1 project metadata is not fetched and only v2 project queries are made.
2025-10-21 19:09:14 -06:00
Kynan Ware
ec526bf72b Inject Detector mock in edit command tests
Added Detector field with EnabledDetectorMock to EditOptions in issue and PR edit command tests to ensure feature detection logic is exercised during test runs. Also updated EditableOptionsFetch signature in pr/edit/edit_test.go to include projectsV1Support parameter for compatibility with shared.FetchOptions.
2025-10-21 15:55:42 -06:00
Kynan Ware
43e834a691
Apply suggestion from @babakks
Co-authored-by: Babak K. Shandiz <babakks@github.com>
2025-10-02 09:55:58 -06:00
Kynan Ware
8d85946098
Apply suggestion from @babakks
Co-authored-by: Babak K. Shandiz <babakks@github.com>
2025-10-02 09:55:45 -06:00
Kynan Ware
bf728893fa Fix argument order in httpStubs test functions
Swaps the argument order of the httpStubs functions in edit_test.go to match the expected (t *testing.T, reg *httpmock.Registry) signature. This improves consistency and prevents potential confusion or errors when calling these test helpers.
2025-10-02 09:54:01 -06:00
Kynan Ware
87468f40db Refactor PR reviewer editing to use REST API and optimize team fetch
Switches pull request reviewer add/remove operations from GraphQL to the REST API, enabling separate add and remove calls for reviewers and teams. Refactors reviewer editing logic to avoid fetching organization teams unless required for interactive editing, improving performance for non-interactive flows. Updates tests and supporting code to reflect the new reviewer management and metadata fetching behavior.
2025-09-30 10:45:44 -06:00
Babak K. Shandiz
58ed691a6c
test: remove references to AssignedActorsUsed field
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-07-01 11:19:13 +01:00
Babak K. Shandiz
2c86246a1a
test: verify providing a URL arg affects the base repo
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-07-01 11:18:38 +01:00
Kynan Ware
ed4b90104f test(pr): Add tests for actor assignees 2025-06-03 14:30:19 +01:00
Andy Feller
a24d39ac87 Fix test, remove partial standalone test 2025-06-03 13:48:01 +01:00
Andy Feller
cde860be88 Iterate on pr edit problems with existing assignees
This commit is a handful of changes around `gh pr edit --add-assignee` behavior.  Most notably, fixing a bug where the assigned actors weren't being dropped.

In addition to this, I was refactoring the testing setup to allow for individual test table scenarios could be contained.
2025-06-03 13:33:52 +01:00
William Martin
793a7ff459 Fix pr edit when URL is provided 2025-06-02 15:07:55 +02:00
Kynan Ware
d932934119 Merge branch 'trunk' into kw/gh-cli-epic-900-actors-are-assignable 2025-05-16 12:49:52 -06:00
Kynan Ware
ec7c8ed844
test(pr edit): fix typo in test name
Co-authored-by: Andy Feller <andyfeller@github.com>
2025-05-15 13:41:38 -06:00
Kynan Ware
a03c9cec7b Merge branch 'kw/gh-cli-epic-900-actors-are-assignable' into kw/gh-cli-909-911-assign-actors-to-prs 2025-05-15 09:42:39 -06:00
Kynan Ware
d72018d312 feat(pr edit): fetch assignable actors 2025-05-15 09:33:36 -06:00
Kynan Ware
f559068106 feat(pr edit): fetch assigned actors 2025-05-15 09:33:36 -06:00
Kynan Ware
999ffbdfe7
Merge pull request #10960 from cli/kw/gh-cli-901-910-assign-actors-to-issues
`gh issue edit`: actors are assignable to issues
2025-05-15 09:24:32 -06:00
Babak K. Shandiz
5dca16fd41
Update test case for removing all reviewers
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-05-13 10:13:45 +01:00
Babak K. Shandiz
ce710aa249
Add test to verify removing all reviewers
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-05-12 15:15:43 +01:00
Kynan Ware
ee9d169204 feat(issue edit): fetch assignable actors 2025-05-09 15:13:11 -06:00
William Martin
55cd3c34cd Feature detect v1 projects on pr edit 2025-05-07 16:17:15 +02:00
Babak K. Shandiz
c9fb4ed099
Verify --milestone and --remove-milestone are not assignable at the same time
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-07-28 15:44:05 +01:00
Babak K. Shandiz
605b4b19e1
Assert correct parsing of --remove-milestone option
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-07-28 15:43:38 +01:00
Babak K. Shandiz
6dc8cc41d0
Verify --body and --body-file are not assignable at the same time 2024-07-28 15:41:54 +01:00
William Martin
5007c18f5f Fix unused params across project 2024-05-07 17:50:43 +02:00
Sam Coe
08a1231178
Allow retrieving projectItems in JSON and allow adding/removing user owned projects (#7007) 2023-02-15 22:14:59 +00:00
Sam Coe
138da0f969
Fix adding/removing projects using flags for edit commands (#6955) 2023-02-06 08:28:38 +11:00
Ilya Yatsishin
179e9c256d
Add projectsV2 support to issue create, issue edit, pr create, and pr edit (#6735)
Co-authored-by: pshevche <pavel.shevchenko.95@gmail.com>
Co-authored-by: Sam Coe <samcoe@users.noreply.github.com>
2023-01-19 22:13:09 +00:00
Natthakit Susanthitanon
33779630da
Exclude the current user from reviewers when creating pr (#6464) 2022-12-08 08:51:35 +02:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Mislav Marohnić
db50b54513 Simplify GraphQL mutations whose response we are not interested in 2021-12-08 13:35:19 +01:00
Des Preston
886f5e0e78 Avoid race condition when updating labels
Update labels using the `addLabelsToLabelable` and
`removeLabelsFromLabelable` mutations instead of via the `updateIssue`
mutation that replaces the entire set of labels. This prevents the edit
operation from clobbering any unseen changes to the list of labels.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-12-08 13:29:47 +01:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
c50d390cf5 Fix tests 2021-05-07 22:09:58 +02:00
Mislav Marohnić
9bdc63c4ca Eliminate API overfetching in pr commands
This completely rewrites the PR lookup mechanism so that the caller
must specify the GraphQL fields to query for each PR. Additionally, this
fixes some export problems with `pr view --json`.

Features:

- Each pr command now gets assigned a concept of a Finder. This makes it
  easier to stub the PR in tests without having to stub the underlying
  HTTP calls or git invocations.

- `pr view --web` is much faster since it only fetches the "url" field.

- `pr diff 123` now skips a whole API call where a whole PR was
  unnecessarily preloaded just to access its diff in a subsequent call.

- PullRequestGraphQL query builder is now used to construct queries.

- A bunch of individual commands are now freed of having to know about
  concepts such as BaseRepo, Branch, Config, or Remotes.
2021-04-30 20:34:36 +02:00
Cristian Dominguez
8bfe64d593 Accept --body-file flag if --body is supported 2021-03-15 15:12:41 +01:00
Sam
a49654970c
Merge pull request #3024 from cli/normalize-pr-commands
Normalize pr command arguments
2021-02-26 10:31:06 -08:00
Sam Coe
9d062ed8fc
Normalize pr command arguments 2021-02-23 09:17:35 -08:00
boonhong
732e919a83 Add pr edit --base to change the base branch of a PR 2021-02-24 00:15:04 +08:00
Sam Coe
4fdf28d8a4
Change behavior of slice flags for issue edit and pr edit commands 2021-02-12 14:42:21 -08:00
Sam Coe
a47ee660a7
Pr edit command 2021-02-12 10:08:44 -08:00