Commit graph

1024 commits

Author SHA1 Message Date
Kynan Ware
7477bdb690 refactor(pr status): remove ChecksStatus slow path
All supported GHES versions (3.16 through 3.20) support the
checkRunCountsByState and statusContextCountsByState fields on
StatusCheckRollupContextConnection. The slow path that iterated
individual CheckContext nodes in ChecksStatus() is dead code.

This commit:

- Removes the slow path from ChecksStatus(), keeping only the
  aggregated counts-by-state path
- Removes parseCheckStatusFromCheckConclusionState (no callers remain)
- Removes CheckRunAndStatusContextCounts from PullRequestFeatures
  and its introspection detection
- Consolidates the two feature detection introspection queries into
  one (PullRequest + WorkflowRun fits within the platform limit of
  two __type expressions)
- Removes the errgroup dependency from feature detection
- Always uses statusCheckRollupWithCountByState in pr status queries
- Updates pr view fixtures to include counts-by-state fields

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 15:21:17 -06:00
Kynan Ware
1c274a8a56 fix(pr status): don't count cancelled checks as failures
When a GitHub Actions workflow uses concurrency with cancel-in-progress,
cancelled runs were counted as failures in `gh pr status` and
`gh pr view`, even when a newer run for the same check name succeeded.
The GitHub web UI and `gh pr checks` both handle this correctly.

Three changes fix this:

1. Add a `cancelled` check status category. Cancelled runs are now
   excluded from all summary counts (passing/failing/pending) and
   subtracted from the total, matching the web UI behavior.

2. Move `eliminateDuplicates` from pkg/cmd/pr/checks to
   `api.EliminateDuplicateChecks` (exported). The function operates
   entirely on `api.CheckContext` and is now shared by both `pr checks`
   and `ChecksStatus()` (used by `pr status` and `pr view`).

3. Apply deduplication in the `ChecksStatus()` slow path, keeping only
   the most recent run per check name — consistent with `pr checks`.

Fixes #12895

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 12:33:31 -06:00
Yuvraj Angad Singh
78891fc6e5
Merge branch 'trunk' into feature/pr-diff-exclude 2026-03-09 19:35:51 +05:30
yuvrajangadsingh
ea83ca0ca9 refactor: change extractFileName param from []byte to string 2026-03-09 19:26:29 +05:30
Kynan Ware
7198d270b4 Add generic actorDisplayName for all actor display names
Replace copilotDisplayName with actorDisplayName(typeName, login, name)
which handles all actor types: known bots get friendly names (e.g.
Copilot → 'Copilot (AI)'), regular bots return login, users with
names return 'login (Name)', others return login.

All DisplayName() methods on Author, CommentAuthor, GitHubUser,
AssignableUser, AssignableBot, RequestedReviewer, and ReviewerBot
now delegate to actorDisplayName with their available fields.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-06 11:55:09 -07:00
Kynan Ware
04bc0d27f4 Show friendly Copilot (AI) name in gh pr view
Add CopilotDisplayName helper that translates known Copilot bot
logins (copilot-pull-request-reviewer, copilot-swe-agent) to the
friendly 'Copilot (AI)' display name. Applied to:

- PullRequestReview.AuthorLogin() — review comment author
- Comment.AuthorLogin() — PR/issue comment author
- parseReviewers() in pr view — reviewer list display

This ensures gh pr view shows 'Copilot (AI)' instead of the raw
'copilot-pull-request-reviewer' login for both the reviewer status
line and any review comments left by Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-06 11:19:43 -07:00
yuvrajangadsingh
a331ef7f8f fix: align example indentation with codebase convention 2026-03-06 23:07:32 +05:30
yuvrajangadsingh
d7f1d8e89d fix: address review feedback for --exclude flag
- add usage examples to --help output
- use path.Match instead of filepath.Match for OS-consistent behavior
- rename patterns to excludePatterns for clarity
- simplify splitDiffSections using strings.Split
2026-03-06 23:07:32 +05:30
yuvrajangadsingh
8bd48afa87 fix: share diffHeaderRegexp between changedFilesNames and extractFileName, fix gofmt 2026-03-06 23:07:32 +05:30
yuvrajangadsingh
18536dc2b1 feat(pr diff): add --exclude flag to filter files from diff output
Add a new --exclude (-e) flag to gh pr diff that allows users to exclude
files matching glob patterns from the diff output. This is useful for
filtering out auto-generated files, vendor directories, or other noise
when reviewing pull requests.

Supports standard glob patterns and can be specified multiple times.
Patterns match against both the full path and basename.

Closes #8739
2026-03-06 23:07:32 +05:30
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
1bba50b3e0 Fix duplicate reviewers in gh pr edit by passing logins as defaults
Use DefaultLogins instead of Default display names when calling
MultiSelectWithSearch for reviewers. The dedup logic in the
prompter compares keys (logins) against defaults, so passing
display names like 'mxie (Melissa Xie)' prevented deduplication
against search result keys like 'mxie'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 15:44:25 -07:00
Kynan Ware
08c7a4c207 Replace @copilot with Copilot reviewer login in gh pr create
Wire CopilotReviewerReplacer into NewIssueState so that
`gh pr create --reviewer @copilot` correctly resolves to the
copilot-pull-request-reviewer bot login, matching the behavior
already implemented in gh pr edit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 15:15:33 -07:00
Kynan Ware
49f1bd8800 Add TODO requestReviewsByLoginCleanup on GHES ID-based reviewer path
Mark the GHES ID-resolution branch in AddMetadataToIssueParams
for cleanup once GHES supports requestReviewsByLogin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 10:58:23 -07:00
Kynan Ware
07138b6edf Remove /slug team reviewer shorthand normalization
Team reviewers must be provided as fully qualified org/teamname.
Remove the /slug shorthand that auto-prefixed the repo owner,
as this format is not supported.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 10:58:08 -07:00
Kynan Ware
37776cf2e6 Add TODO requestReviewsByLoginCleanup on static reviewer MultiSelect
Mark the legacy static MultiSelect reviewer path for cleanup once
GHES supports requestReviewsByLogin and search-based selection can
be used universally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 10:57:45 -07:00
Kynan Ware
dd7e44ee0a Check state.ActorReviewers in MetadataSurvey reviewer search gate
Gate search-based reviewer selection on both state.ActorReviewers
and the search function being available, consistent with the
ActorAssignees pattern used for assignees.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 10:57:28 -07:00
Kynan Ware
48951aca01 Fix invalid ANSI SGR escape code in JSON and diff colorization
Replace `1;38` with `1;37` (bold white) in the delimiter/header
color constant. SGR parameter 38 is the extended foreground color
prefix and requires sub-parameters (e.g. `38;5;n` or `38;2;r;g;b`),
so using it bare produces an invalid escape sequence. Most terminals
silently ignore the malformed parameter, masking the bug.

Fixes cli/cli#12683

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 17:52:01 -07:00
Kynan Ware
9de48154de Add missing TODO comments for featuredetection if-statements
Add greppable TODO identifiers above all if-statements that reference
featuredetection struct fields, as required by the featuredetection
linter. This ensures every feature detection branch is tagged for
future cleanup when GHES gains support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-16 14:24:32 -07:00
William Martin
2b5c3b5ecb document fork default branch behavior 2026-02-13 15:36:37 +01:00
William Martin
7448aed8ab fork default branch only in pr create 2026-02-12 16:56:14 +01:00
Kynan Ware
1d730951d2 Use org/slug format in test fixtures and remove /slug normalization 2026-02-11 14:51:12 -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
e361335e5c Skip reviewer metadata fetch when using search-based selection 2026-02-11 13:18:39 -07:00
Kynan Ware
38661646ee Update test assertions to expect org/slug team format 2026-02-11 13:18:07 -07:00
Kynan Ware
1209b24e69 Partition bot reviewers separately for RequestReviewsByLogin 2026-02-11 13:16:03 -07:00
Kynan Ware
db167d3116 Preserve org/slug format for team reviewer slugs 2026-02-11 13:15:14 -07:00
Kynan Ware
cf08f4d51e
Apply suggestion from @BagToad 2026-02-10 11:08:12 -07:00
Kynan Ware
7373de3e70
Remove redundant comment 2026-02-10 10:58:23 -07:00
Kynan Ware
dd9ab7152b
Don't swallow error from FD
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-10 10:54:03 -07:00
Kynan Ware
620261fea4
Remove redundant comments 2026-02-10 10:53:30 -07:00
Kynan Ware
9904f7d1b9 gh pr create: CCR and multiselectwithsearch 2026-02-04 14:56:05 -07:00
Kynan Ware
a9a0486c70 Clarify comment on reviewer API behavior
Update comment in FetchOptions to specify that the APIs used for both GHES and GitHub.com accept user logins and team slugs directly, clarifying why non-interactive flows with Add/Remove don't need to fetch reviewers/teams. Comment-only change; no functional modifications.
2026-01-30 11:33:22 -07:00
Kynan Ware
aac223ab71 Clarify assignee/reviewer fetching behavior
Add clarifying comment in pkg/cmd/pr/edit/edit.go to note that missing assignee/reviewer search functions trigger a downstream fallback to legacy fetching. In pkg/cmd/pr/shared/editable.go remove a redundant line and add a TODO urging migration of non-interactive assignee updates to use the new logins input with ReplaceActorsForAssignable to avoid unnecessary fetching. These are comment and doc changes to clarify intent and future improvements.
2026-01-30 11:29:11 -07:00
Kynan Ware
4569aae0e4 Clarify EditableReviewers comment
Remove a redundant struct-level comment and update the DefaultLogins field comment in pkg/cmd/pr/shared/editable.go to more accurately describe its purpose: used to disambiguate actors from display names rather than to compute add/remove sets.
2026-01-30 11:20:30 -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
846d6619b7 Remove redundant comment 2026-01-28 10:50:54 -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
968a912a07 Remove outdated TODO comments in survey.go
Cleaned up obsolete TODO comments related to assignee and reviewer selection logic in the MetadataSurvey function.
2026-01-26 15:05:18 -07:00
Kynan Ware
a8053d6e93 Remove redundant comment in editRun test 2026-01-26 14:56:50 -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
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
e3a3a01f2d Add comments to assigneeSearchFunc for clarity
Added detailed comments to the assigneeSearchFunc explaining its purpose and the importance of updating assignable actors metadata for later ID resolution when mutating assignees with the GraphQL API.
2026-01-26 13:29:22 -07:00
Kynan Ware
30cfbd9fdd Apply suggestions from code review
Co-authored-by: Babak K. Shandiz <babakks@github.com>
2026-01-26 13:29:22 -07:00
Kynan Ware
c0df49043f Clarify TODO comment for reviewer search function
Updated the TODO comment to specify wiring up the reviewer search function if or when it exists, providing clearer intent for future development.
2026-01-26 13:29:22 -07:00
Kynan Ware
ad8c770013 Only support assignee searchfunc on GitHub.com 2026-01-26 13:29:22 -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
d46f42a752 Refactor MultiSelectWithSearch to use result struct
Refactored the MultiSelectWithSearch function and related interfaces to use a MultiSelectSearchResult struct instead of multiple return values. This change improves clarity and extensibility of the search function signature, and updates all usages, mocks, and tests accordingly.
2026-01-26 13:29:22 -07:00
Kynan Ware
7e7f8c6f6e Pass editable to assigneeSearchFunc and update metadata
The assigneeSearchFunc now receives the editable struct to update its Metadata.AssignableActors field with suggested assignable actors. This change ensures that the editable struct has the necessary actor metadata for later PR updates.
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