Commit graph

5566 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
3651c289ed Show friendly display names in gh issue view
Apply DisplayName() to author and assignee display in issue view,
consistent with the pr view changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-06 12:01:06 -07:00
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
yuvrajangadsingh
fdd6388086 refactor: deduplicate scope error handling between api/client.go and project queries
Consolidate duplicated INSUFFICIENT_SCOPES error handling into a single
implementation. The project queries package now calls
api.GenerateScopeErrorForGQL instead of reimplementing the same logic.

Removes duplicated requiredScopesFromServerMessage, scopesRE, and the
associated test (already covered by api/client_test.go).

Fixes #12823
2026-03-05 20:57:32 +05:30
William Martin
e17d203569
Merge pull request #12838 from cli/remove-state-reason-duplicate-detection
Remove unnecessary StateReason and StateReasonDuplicate feature detection
2026-03-05 12:52:00 +01:00
Copilot
ff8873da07
Fix extension install error message showing raw struct instead of owner/repo (#12836)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: williammartin <1611510+williammartin@users.noreply.github.com>
2026-03-05 12:28:54 +01:00
Kynan Ware
4f2304d4e5 Remove StateReason feature detection for issue close
The stateReason field was added in GHES ~3.4, which is far older than
the earliest supported GHES version (3.14). The feature detection and
conditional inclusion of stateReason is therefore unnecessary.

This removes:
- StateReason field from IssueFeatures struct
- GHES introspection query in IssueFeatures() (only ActorIsAssignable
  remains, which is always false on GHES)
- Conditional stateReason field inclusion in issue list
- Feature detection guard in issue close
- Feature detection guard in FindIssueOrPR

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-04 13:31:30 -07:00
Kynan Ware
6b56a23970 Remove unnecessary StateReasonDuplicate feature detection
The DUPLICATE enum variant for IssueClosedStateReason was added in
GHES 3.16, which is older than the earliest supported GHES version.
The feature detection check is therefore unnecessary.

Addresses: https://github.com/cli/cli/pull/12811#issuecomment-3997044372

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-04 13:24:05 -07:00
Kynan Ware
d594c5e918
docs: add examples to gh issue close help text (#12830)
Add examples for closing issues, closing with a comment, closing as
duplicate, and closing with a reason.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Babak K. Shandiz <babakks@github.com>
2026-03-04 14:53:27 +00:00
Takeshi
b9c8d8e023
Merge branch 'trunk' into issue-close-duplicate-of 2026-03-03 22:03:25 -05:00
Mason McElvain
74ff94c3e4 feat(browse): add blame flag 2026-03-03 19:03:40 -07:00
Kynan Ware
4ea9076d81
Merge pull request #12651 from gunadhya/fix-repeating-cmd-gh-issue-develop
`issue develop`: prevent .git/config corruption on repeated `--name` invocation
2026-03-03 18:55:43 -07:00
Kynan Ware
6e979c6b32
Merge pull request #12686 from 4RH1T3CT0R7/add-no-upstream-flag
Add --no-upstream flag to repo clone
2026-03-03 16:01:05 -07:00
Kynan Ware
6045a593a3
Reword --no-upstream help doc 2026-03-03 15:51:27 -07:00
Kynan Ware
d983ae0469
Merge pull request #12623 from LouisLau-art/fix/issue-list-pr-search-qualifier
fix(issue list): reject pull request-only search qualifiers
2026-03-03 14:52:35 -07:00
Louis Shawn
b601b307a4 test(issue list): cover additional PR search qualifier variants 2026-03-03 10:13:57 +08:00
Kynan Ware
60318613d8
Merge pull request #12720 from cli/kw/fix-invalid-ansi
Fix invalid ANSI SGR escape code in JSON and diff colorization
2026-03-02 15:12:15 -07:00
Kynan Ware
ad41bb967d
Merge pull request #12807 from maxbeizer/agent-task-view-json
Add --json support to `gh agent-task view`
2026-03-02 13:36:06 -07:00
Kynan Ware
1a5fb34493
Merge pull request #12806 from maxbeizer/agent-task-list-json
Add --json support to `gh agent-task list`
2026-03-02 13:35:27 -07:00
Kynan Ware
79796d2dc5
Merge pull request #12787 from ManManavadaria/fix-12726/item-edit-draft-issue-partial-update
fix: `gh project item-edit` error when editing Draft Issue with only one (title/body) flag
2026-03-02 12:19:53 -07:00
Kynan Ware
1957a022b6
Merge pull request #12652 from VishnuVV27/fix-issue-view-comments-redundancy
Fix redundant API call in gh issue view --comments (#12606)
2026-03-02 10:58:41 -07:00
Louis Shawn
5194256928 fix(issue list): reject pull request-only search qualifiers 2026-03-02 10:50:15 -07:00
Kynan Ware
1c36686a61
Merge branch 'trunk' into 2722-fix-fork-remote-flag 2026-03-02 10:22:27 -07:00
Kynan Ware
0f5355e8b4
Merge pull request #12781 from itchyny/api-compile-json-content
Use pre-compiled regexp for matching Content-Type
2026-03-02 10:16:37 -07:00
Devraj Mehta
351df5b9d1
Set COPILOT_GH env var when launching Copilot CLI
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-02 10:25:47 -05:00
gunadhya
ee8014a4d9 Simplify progress indicators in issue develop 2026-03-02 17:01:57 +05:30
Max Beizer
d908af3484 Emit null for zero createdAt/updatedAt values
Consistent with completedAt handling. Addresses Copilot review feedback
from companion PR #12807.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 10:18:37 -06:00
Max Beizer
0d05a8acca Address Copilot review feedback
- Prioritize --json output over --log/--follow so JSON is not silently ignored
- Emit null for zero createdAt/updatedAt values, consistent with completedAt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 10:18:21 -06:00
Max Beizer
ceb8cf2561 Polish --json support for agent-task view
- Rename 'status' field to 'state' for consistency with struct and UI
- Add missing JSON fields: completedAt, user, pullRequestTitle, pullRequestState
- Add test for nil PullRequest with --json
- Expand existing JSON test to cover new fields

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 09:09:08 -06:00
Max Beizer
c5c107aa8b Polish --json support for agent-task list
- Fix empty results returning error instead of [] when --json is used
- Rename 'status' field to 'state' for consistency with struct and UI
- Add missing JSON fields: completedAt, user, pullRequestTitle, pullRequestState
- Add test for empty results with --json
- Add test for nil PullRequest with --json

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 09:08:18 -06:00
Max Beizer
250d5a850a Fix gofmt alignment in view_test.go
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 08:57:53 -06:00
Takeshi
01c83acfe8 Add --duplicate-of flag and duplicate reason to gh issue close
Support closing issues as duplicates via --reason duplicate and
--duplicate-of <issue> flags. The --duplicate-of flag accepts an issue
number or URL, validates it references a different issue (not a PR),
and passes the duplicate issue ID to the closeIssue mutation.

Feature detection checks whether the GHES instance supports the
DUPLICATE enum value in IssueClosedStateReason before using it.
2026-02-28 20:10:07 -05:00
Max Beizer
7241b42ecf Add --json support to gh agent-task view
Add --json, --jq, and --template flags to `gh agent-task view`,
consistent with the pattern used by `gh pr view --json`,
`gh issue view --json`, etc.

This reuses the same ExportData interface and SessionFields defined
for list, applying them to the single-session view output.

Closes https://github.com/cli/cli/issues/12805 (partial)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 09:22:28 -06:00
Max Beizer
0d9e6af3da Add --json support to gh agent-task list
Add --json, --jq, and --template flags to `gh agent-task list`,
consistent with the pattern used by `gh pr list --json`,
`gh issue list --json`, etc.

This implements the ExportData interface on capi.Session and defines
SessionFields for the available JSON fields:
id, name, status, repository, createdAt, updatedAt,
pullRequestNumber, pullRequestUrl.

Closes https://github.com/cli/cli/issues/12805 (partial)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 09:20:13 -06:00
ManManavadaria
d21544c085 fix(project/item-edit): preserve title/body when editing draft issue with partial flags 2026-02-26 16:23:37 +05:30