Skip to content

Conversation

@iamazeem
Copy link
Contributor

@iamazeem iamazeem commented May 7, 2025

Fixes #10563.

Acceptance Tests

gh issue view --help

$ bin/gh issue view --help
Display the title, body, and other information about an issue.

With `--web` flag, open the issue in a web browser instead.

For more information about output formatting flags, see `gh help formatting`.

USAGE
  gh issue view {<number> | <url>} [flags]

FLAGS
  -c, --comments          View issue comments
  -q, --jq expression     Filter JSON output using a jq expression
      --json fields       Output JSON with the specified fields
  -t, --template string   Format JSON output using a Go template; see "gh help formatting"
  -w, --web               Open an issue in the browser

INHERITED FLAGS
      --help                     Show help for command
  -R, --repo [HOST/]OWNER/REPO   Select another repository using the [HOST/]OWNER/REPO format

JSON FIELDS
  assignees, author, body, closed, closedAt, closedByPullRequestsReferences,
  comments, createdAt, id, isPinned, labels, milestone, number, projectCards,
  projectItems, reactionGroups, state, stateReason, title, updatedAt, url

LEARN MORE
  Use `gh <command> <subcommand> --help` for more information about a command.
  Read the manual at https://cli.github.com/manual
  Learn about exit codes using `gh help exit-codes`
  Learn about accessibility experiences using `gh help accessibility`

gh issue view <number> --json closedByPullRequestsReferences

$ bin/gh issue view 10529 --repo cli/cli --json closedByPullRequestsReferences
{
  "closedByPullRequestsReferences": [
    {
      "id": "PR_kwDODKw3uc6Nbtk1",
      "number": 10544,
      "repository": {
        "id": "MDEwOlJlcG9zaXRvcnkyMTI2MTMwNDk=",
        "name": "cli",
        "owner": {
          "id": "MDEyOk9yZ2FuaXphdGlvbjU5NzA0NzEx",
          "login": "cli"
        }
      },
      "url": "https://github.com/cli/cli/pull/10544"
    }
  ]
}

Prompt not resetting on error

Fixed another related issue of prompt not getting back to normal when the issue is not found e.g. issues are disabled:

$ bin/gh issue view 101 --repo iamazeem/cli
the 'iamazeem/cli' repository has disabled issues

Before:

gh-issue-view-prompt-error

After:

gh-issue-view-prompt-error-fixed

Signed-off-by: Azeem Sajid azeem.sajid@gmail.com

@iamazeem iamazeem requested a review from a team as a code owner May 7, 2025 08:27
@iamazeem iamazeem requested a review from BagToad May 7, 2025 08:27
@iamazeem iamazeem temporarily deployed to cli-automation May 7, 2025 08:27 — with GitHub Actions Inactive
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label May 7, 2025
@babakks babakks requested review from babakks and Copilot and removed request for BagToad May 7, 2025 09:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR exposes the closedByPullRequestsReferences field in the JSON output of gh issue view, including fetching, GraphQL query support, API types, export formatting, and tests.

  • Added closedByPullRequestsReferences to view JSON flags and importer/exporter logic
  • Implemented preloadClosedByPullRequestsReferences for paginated fetching
  • Updated GraphQL query builder, API models, export functions, and tests

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/cmd/issue/view/view_test.go Added new JSON field to TestJSONFields
pkg/cmd/issue/view/view.go Renamed lookupFields to fields, added closed-by-PR preload and field handling
pkg/cmd/issue/view/http.go Implemented preloadClosedByPullRequestsReferences
api/query_builder.go Added GraphQL fragment for closedByPullRequestsReferences
api/queries_issue.go Defined ClosedByPullRequestsReferences in Issue model
api/export_pr_test.go Added test case for exporting linked pull requests
api/export_pr.go Added export logic for closedByPullRequestsReferences

iamazeem added 2 commits May 7, 2025 14:37
…f github.com:iamazeem/cli into 10563-gh-issue-view-expose-json-field-for-linked-prs
Copy link
Member

@babakks babakks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @iamazeem! It's very good. 🎉

I just had a few points, mostly regarding the side changes.

@iamazeem iamazeem requested a review from babakks May 7, 2025 11:43
Copy link
Member

@babakks babakks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks again!

@babakks
Copy link
Member

babakks commented May 7, 2025

Tried it on my end again, and the result is as defined by the A/C.

@babakks babakks merged commit ee281fd into cli:trunk May 7, 2025
9 checks passed
@iamazeem iamazeem deleted the 10563-gh-issue-view-expose-json-field-for-linked-prs branch May 7, 2025 13:21
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 20, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.72.0` -> `v2.73.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.73.0`](https://github.com/cli/cli/releases/tag/v2.73.0): GitHub CLI 2.73.0

[Compare Source](cli/cli@v2.72.0...v2.73.0)

#### :copilot: Copilot Coding Agent Support

You can now assign issues to GitHub Copilot directly from `gh`, just as you would assign them to a teammate. Use `gh issue edit <number> --add-assignee @&#8203;copilot` to assign the GitHub Copilot coding agent, and Copilot will work in the background to understand the issue, propose a solution, and open a pull request when it's ready for your review. If you run `gh issue edit` interactively, `Copilot (AI)` will be displayed as a potential assignee. This feature is available for GitHub Copilot Pro+ and Copilot Enterprise subscribers. For more details, refer to [the full changelog post for Copilot coding agent](https://github.blog/changelog/2025-05-19-github-copilot-coding-agent-in-public-preview/).

#### What's Changed

##### ✨ Features

-   Copilot is assignable to issues and pull requests with `issue edit` and `pr edit` by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10992
    -   `gh issue edit`: actors are assignable to issues by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10960
    -   `gh pr edit`: Assign actors to pull requests by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10984
    -   `issue edit`, `pr edit`: handle display names in interactive assignee editing   by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10990
    -   `issue edit`, `pr edit`: Support special non-interactive (flags) assignee name `@copilot` by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10991
-   \[gh issue/pr comment] Add support for last comment delete for issues and MRs by [@&#8203;sinansonmez](https://github.com/sinansonmez) in cli/cli#10596
-   \[gh issue view] Expose `closedByPullRequestsReferences` JSON field by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10941
-   Accessible prompter always displays selection defaults in a format readable by a screen reader by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10937

##### 🐛 Fixes

-   Fix `StatusJSONResponse` usage by [@&#8203;babakks](https://github.com/babakks) in cli/cli#10810
-   Fix panic on `gh pr view 0` by [@&#8203;nopcoder](https://github.com/nopcoder) in cli/cli#10729
-   Fix flakey test for accessible prompter by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10918
-   Fix accessible prompter flaky tests by [@&#8203;babakks](https://github.com/babakks) in cli/cli#10977
-   Handle missing archive URLs on release download by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10947
-   Fix bug when removing all MR reviewers by [@&#8203;babakks](https://github.com/babakks) in cli/cli#10975

##### 📚 Docs & Chores

-   Feature detect v1 projects on pr view by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10821
-   Feature detect v1 projects on non-interactive pr create by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10909
-   Feature detect v1 projects on web mode pr create by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10911
-   Feature detect v1 projects on interactive `pr create` by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10915
-   Feature detect v1 projects on pr edit by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10942
-   Move predicate type filtering in `gh attestation verify` by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10670
-   Improve assertion for disabled echo mode by [@&#8203;babakks](https://github.com/babakks) in cli/cli#10927

##### :dependabot: Dependencies

-   chore(deps): bump actions/attest-build-provenance from 2.2.2 to 2.3.0 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10886
-   chore(deps): bump github.com/cpuguy83/go-md2man/v2 from 2.0.6 to 2.0.7 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10869

#### What's Changed

#### New Contributors

-   [@&#8203;sinansonmez](https://github.com/sinansonmez) made their first contribution in cli/cli#10596
-   [@&#8203;nopcoder](https://github.com/nopcoder) made their first contribution in cli/cli#10729

**Full Changelog**: cli/cli@v2.72.0...v2.73.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xNS4wIiwidXBkYXRlZEluVmVyIjoiNDAuMTUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add field to retrieve linked PRs (closingPRsReferences) in gh issue view <number

3 participants