Commit graph

262 commits

Author SHA1 Message Date
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
e6d9019bc9 fix(pr create): use login-based assignee mutation on github.com
When ActorAssignees is true (github.com), pass assignee logins directly
to the ReplaceActorsForAssignable mutation instead of resolving logins
to node IDs. This eliminates the need to bulk fetch all assignable
users/actors and fixes a bug where providing assignees via CLI flag
and then interactively adding metadata would fail with 'not found'
because the cached MetadataResult had no assignee data.

Changes:
- Set state.ActorAssignees = true in pr create (was missing)
- AddMetadataToIssueParams: pass assigneeLogins when ActorAssignees
  is true, skip fetch and ID resolution entirely
- CreatePullRequest/IssueCreate: call ReplaceActorsForAssignableByLogin
  after creation to assign via logins
- Consolidate replaceActorsForAssignable mutation into api/ package
  (ReplaceActorsForAssignableByLogin + ReplaceActorsForAssignableByID)
- Remove duplicate replaceActorAssigneesForEditable from editable_http.go
- Add TODO replaceActorsByLoginCleanup markers on edit paths

Fixes cli/cli#13000

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-23 15:21:20 -06:00
Kynan Ware
93c4340f29
Merge pull request #12627 from cli/kw/pr-create-multi-select-with-search-ccr
`gh pr create`: login-based reviewer requests and search-based interactive selection
2026-03-06 10:24:19 -07:00
Kynan Ware
6341588f90 Add TODO requestReviewsByLoginCleanup in CreatePullRequest
Add a cleanup TODO comment above the GHES feature detection branch
in CreatePullRequest so we can track removing the ID-based reviewer
request path once GHES supports requestReviewsByLogin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 10:56:31 -07:00
yuvrajangadsingh
de61b2b65d feat(pr): add changeType field to files JSON output
Add the changeType field from the PullRequestChangedFile GraphQL type
to the PullRequestFile struct. This exposes the file status (added,
modified, deleted, renamed, copied, changed) in gh pr list --json files
and gh pr view --json files output.

Closes #11385
2026-03-01 15:35:05 +05:30
Kynan Ware
72a6e9f3a7 Move PR review queries from queries_pr.go to queries_pr_review.go
Consolidate all review-related types, methods, and functions into
queries_pr_review.go for better code organization. The file is now
ordered by logical sections: review data types, review status, review
requests, reviewer candidates, API operations, and helpers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-13 13:40:59 -07:00
Kynan Ware
1cb776384e Normalize /slug team shorthand to org/slug and fix docs 2026-02-11 14:33:13 -07:00
Kynan Ware
a8655bcda9 Include bot logins in login-based reviewer mutation guard 2026-02-11 13:55:57 -07:00
Kynan Ware
ad64d10bf4 Wire bot reviewer logins through CreatePullRequest 2026-02-11 13:16:23 -07:00
Kynan Ware
78aaa87718 Add toGitHubV4Strings helper to reduce code duplication 2026-02-05 14:01:21 -07:00
Kynan Ware
04bf86a72c Address PR review comments
Address PR review comments: code consistency and DRY improvements

- Add botTypeName const for consistency with teamTypeName
- Create extractTeamSlugs helper using strings.SplitN to simplify
  team slug extraction logic
- Replace duplicate code in AddPullRequestReviews and
  RemovePullRequestReviews with extractTeamSlugs helper
- Fix ClientMutationId naming with explicit graphql tag for
  consistency with other mutations in the codebase
2026-02-05 14:01:21 -07:00
Kynan Ware
c0febc1ac8 Add toGitHubV4Strings helper to reduce code duplication 2026-02-04 15:18:49 -07:00
Kynan Ware
ebf932a043 Address PR review comments
Address PR review comments: code consistency and DRY improvements

- Add botTypeName const for consistency with teamTypeName
- Create extractTeamSlugs helper using strings.SplitN to simplify
  team slug extraction logic
- Replace duplicate code in AddPullRequestReviews and
  RemovePullRequestReviews with extractTeamSlugs helper
- Fix ClientMutationId naming with explicit graphql tag for
  consistency with other mutations in the codebase
2026-02-04 15:15:29 -07:00
Kynan Ware
9904f7d1b9 gh pr create: CCR and multiselectwithsearch 2026-02-04 14:56:05 -07:00
Kynan Ware
c8b1409803 Use unfiltered totalCount for reviewer 'more results' display
Query aliased fields without search filter to get stable counts.
2026-01-29 12:54:04 -07:00
Kynan Ware
484526da77 Include name in reviewer display for existing review requests
Fetch name field in reviewRequests GraphQL query and show as 'login (Name)'.
2026-01-29 12:46:26 -07:00
Kynan Ware
2d191e5ba0 Implement cascading quota for reviewer suggestions
Each source (suggestions, collaborators, teams) has base quota of 5.
Unfilled slots cascade to later sources, allowing up to 15 total.
Adds unit tests with HTTP mocks.
2026-01-29 11:30:08 -07: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
7f8ca2ca81 Fix return proper slug only for ReviewerTeam 2026-01-29 10:23:18 -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
23e80a9d24 Remove outdated comment in SuggestedAssignableActors
Deleted a comment about the query variable being passed as null when empty, as it is no longer relevant or necessary.
2026-01-26 15:09:58 -07:00
Kynan Ware
28e07666f8 Return total assignee count in SuggestedAssignableActors
Updated SuggestedAssignableActors to return the total count of available assignees in the repository. Modified assigneeSearchFunc to use this count to calculate and display the number of additional assignees beyond the current results.
2026-01-26 14:33:45 -07:00
Kynan Ware
48bea46504 Remove unused Viewer struct from SuggestedAssignableActors
Deleted the Viewer struct from the responseData type in SuggestedAssignableActors as it was not being used.
2026-01-26 13:48:22 -07:00
Kynan Ware
dc105ce7a4 Simplify variables map in SuggestedAssignableActors
Refactored the construction of the variables map by directly assigning the 'query' key, removing the conditional logic for nil assignment.
2026-01-26 13:29:22 -07:00
Kynan Ware
346bd8c002 Simplify suggested assignable actors
Simplifies SuggestedAssignableActors by no longer including the viewer in the returned actors list when the query is blank. Removes related logic and variables for viewer handling.
2026-01-26 13:29:22 -07:00
Kynan Ware
38f9d7891b Fix linter and mock prompter signature 2026-01-26 13:29:22 -07:00
Kynan Ware
f6a09a3e5c Apply suggestions from code review
Co-authored-by: Babak K. Shandiz <babakks@github.com>
2026-01-26 13:29:22 -07:00
Kynan Ware
d04317c273 Add dynamic assignee search to PR edit flow
Introduces SuggestedAssignableActors API query and wires up a dynamic assignee search function in the PR edit command. Updates Editable and EditPrompter interfaces to support search-based multi-select for assignees, improving the user experience when assigning users to pull requests.
2026-01-26 13:29:22 -07:00
Kynan Ware
273fccd908 Check user and teams nil state instead of length 2025-11-10 11:09:14 -07:00
Kynan Ware
e154601f7d Ensure empty arrays for reviewers in PR API calls
Updated AddPullRequestReviews and RemovePullRequestReviews to send empty arrays instead of null values for reviewers and team_reviewers when no users or teams are specified, as required by the API.
2025-11-07 14:00:28 -07:00
Lucas Melin
6db1441eb6
Return only basic pull request info when reverting a PR
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-10-22 18:02:35 -04:00
Lucas Melin
b229402cab
Return nil when err is nil 2025-10-06 13:27:45 -04:00
Lucas Melin
023a639c8c
feat: include revert PR info in message output 2025-10-06 13:25:31 -04:00
Lucas Melin
9467d66b11
Undo autoformat changes 2025-10-06 13:25:31 -04:00
Lucas Melin
60b6a5eed5
feat: implement pr revert 2025-10-06 13:25:31 -04:00
Kynan Ware
66fae72872 Remove default empty slices in RemovePullRequestReviews
Eliminates unnecessary initialization of users and teams to empty slices in RemovePullRequestReviews. Also updates the request body struct to use 'omitempty' for reviewers and team_reviewers, ensuring empty fields are omitted from the JSON payload.
2025-10-01 16:12:06 -06:00
Kynan Ware
848faf8115 Refactor reviewer partitioning in PR edit command
Extracted logic for splitting reviewer identifiers into users and teams into a new helper function, partitionUsersAndTeams. Updated updatePullRequestReviews to use this function for both adding and removing reviewers, improving code clarity and maintainability. Also clarified comments regarding PR author handling.
2025-10-01 16:02:05 -06:00
Kynan Ware
57fce1dc3a Escape repo owner and name in PR reviewer API paths
Updated AddPullRequestReviews and RemovePullRequestReviews to use url.PathEscape for repo owner and name in API paths. This ensures correct handling of special characters in repository identifiers.
2025-10-01 15:55:24 -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
Kynan Ware
dd424d85fd Add agent task listing command and CAPI client
Introduces a new 'list' subcommand under agent-task for listing agent tasks. Implements a Copilot API client for fetching agent sessions and hydrating them with pull request data. Updates PullRequest and PRRepository types to support new fields. Adds dependencies for msgpack and tagparser.

Co-Authored-By: Babak K. Shandiz <babakks@github.com>
2025-08-28 22:00:35 -06:00
Babak K. Shandiz
00a86a105e
fix: remove AssignedActorsUsed field
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-07-01 11:11:28 +01:00
William Martin
793a7ff459 Fix pr edit when URL is provided 2025-06-02 15:07:55 +02:00
Kynan Ware
f559068106 feat(pr edit): fetch assigned actors 2025-05-15 09:33:36 -06:00
Azeem Sajid
9ed733fa5e
Add closingIssuesReferences JSON field to pr view (#10544)
* [gh pr view] Support `closingIssuesReferences` JSON field

* Support pagination

* Support pagination

* Fix typo

* Add more fields
2025-04-29 11:48:20 +01:00
Dalius Dobravolskas
9414930b5d
Adding option to return baseRefOid in pr view
You need to know exact `baseRefOid` so you could show correct diff.
`baseRefName` is not enough sometimes because branch from which PR was
forked might have changes already.

Example usage:
```
gh pr view --json headRefName,headRefOid,number,baseRefName,baseRefOid,reviewDecision
```
2024-11-19 23:50:45 +02:00
William Martin
8a0d361bac Expose fullDatabaseId for PR json export 2024-07-23 13:23:10 +02:00
Babak K. Shandiz
feb5aa55b9
Add separate type for PullRequest.Mergeable field
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-07-16 15:28:27 +01:00
Babak K. Shandiz
78091c4aff
Fix query parameter name
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-05-09 20:42:46 +01:00
Babak K. Shandiz
cec2ced42f
Improve query variable names
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-05-07 00:19:30 +01:00
Babak K. Shandiz
acef17d6cb
Add ComparePullRequestBaseBranchWith function
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-05-06 23:57:20 +01:00