Commit graph

773 commits

Author SHA1 Message Date
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
7303c44483 Clarify Copilot assignee comment
Reword the comment for CopilotAssigneeLogin to indicate it refers to Copilot when retrieved as an assignee. This updates wording from the previous 'Actor/assignable actors' phrasing for clarity; no code behavior changed.
2026-01-30 11:17:25 -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
cuiweixie
b9c85fff68
typo: dont to don't 2026-01-26 22:25:00 +08:00
Andy Feller
1117477da2 Add test to ensure null values are skipped 2025-12-22 10:16:21 -05:00
Chris Henzie
4a106c1acf fix: prevent panic when processing null project items
The GraphQL API can return `null` nodes in the `projectItems`
connection, causing a runtime panic (nil pointer dereference) when the
CLI attempted to access fields on these nil nodes. This crash occurs
even with personal access tokens with full read access.

Adds a check to safely skip `nil` nodes in `ProjectsV2ItemsForIssue` and
`ProjectsV2ItemsForPullRequest`.

Signed-off-by: Chris Henzie <chrishenzie@google.com>
2025-12-16 11:14:55 -08: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
Babak K. Shandiz
f498f2e882
fix: resolve copyloopvar issues
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:26 +00:00
Babak K. Shandiz
9f65e89760
fix: close resp body (bodyclose)
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:25 +00:00
Babak K. Shandiz
d129b94fc5
refactor: remove returned resp from api.EndpointNeedsScopes
The returned response from `api.EndpointNeedsScopes` causes `bodyclose`
linter to raise a false positive error, assuming it's a new response that
its body needs to be closed.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-11-03 20:05:24 +00:00
Kynan Ware
b90e39ea91
Merge pull request #8826 from lucasmelin/lucasmelin/add-pr-revert-command
feat: implement gh `pr revert`
2025-10-23 13:13:08 -06: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
Babak K. Shandiz
55fbad3e49
test(api): assert SkipDefaultHeaders is honoured
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-13 16:37:32 +01:00
Babak K. Shandiz
b81c2495d2
fix(api): expose SkipDefaultHeaders option
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-13 16:37:04 +01:00
Babak K. Shandiz
b9e04ef83d
test(api): improve NewHTTPClient test assertions
The assertions should check for header values instead of single string,
because when getting a single header value, we get an empty string if
the header is not set or is set to an empty string. So, to make sure a
header is not set we should check the `Values` slice which is `nil` only
if the header is missing.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-13 16:33:03 +01: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
7ff84cff2e
Merge pull request #11797 from cli/github-cli-epic-990
`gh agent-task` commandset
2025-09-23 09:45:59 -06:00
Babak K. Shandiz
1e36e9f1e3
refactor(agent-task/capi): hydrate user data
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-05 12:44:11 +01: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
minxinyi
21b08bdd20
refactor: use slices.Equal to simplify code (#11364)
Signed-off-by: minxinyi <minxinyi6@outlook.com>
2025-08-26 15:29:19 -06:00
Andy Feller
72f5fbbec0 Base changes for PR project items 2025-08-12 20:59:50 -04:00
Andy Feller
7851c9c664 Update gh issue view to show v2 projects
These changes enhance the existing `gh issue view` experience by listing v2 projects in interactive and non-interactive forms.

Additionally, the tests have been enhanced to use a more standard `httpStubs` approach from other tests.
2025-08-12 16:18:45 -04:00
Kynan Ware
addee16531 Refactor and improve RepoMetadata teams test
Renamed the test to clarify its purpose and added an explicit exclusion for the OrganizationTeamList GraphQL query to ensure teams are only fetched when specified. This improves test accuracy and readability.
2025-07-23 09:59:20 -06:00
Kynan Ware
e5feda353f Refactor error assertion in Test_RepoMetadataTeams
Replaces manual error check with require.NoError for consistency and improved readability in the test.
2025-07-22 11:06:50 -06:00
Kynan Ware
449920b40f Add TeamReviewers flag to RepoMetadataInput
Introduces a TeamReviewers boolean to RepoMetadataInput to control whether team reviewers are fetched. Updates RepoMetadata logic to only fetch teams if both Reviewers and TeamReviewers are true. Adds tests to verify correct behavior when TeamReviewers is false.
2025-07-22 10:47:24 -06:00
Andy Feller
260519dc69
Merge pull request #11279 from cli/andyfeller/issue-create-assign-copilot
Assign Copilot during `gh issue create`
2025-07-16 17:01:32 -04:00
Andy Feller
5cf3d3b9a5 Use constant for Copilot name
Based on PR feedback from @bagtoad, this commit creates a new constant for the Copilot bot name, which is used in the assignee / reviewer selection as well as replacing `@copilot` when going to GitHub.com UI
2025-07-16 15:06:43 -04:00
Andy Feller
a8053d19a9 Resolve issue and PR metadata consistently
This commit refactors how `gh issue create` and `gh pr create` retrieve information needed to resolve metadata to be more in line with the approach used in `gh issue edit` and `gh pr edit`.

Previously, both commands used `prshared.fillMetadata(...)` function to retrieve assignees, reviewers, labels, and teams outside of `api.RepoMetadata(..)`.  Now, these commands will consistently use the same logic and data for resolving metadata.
2025-07-11 10:21:17 -04:00
Andy Feller
49821b20f9 Add non-TTY issue create copilot test, todos 2025-07-08 15:19:09 -04:00