Skip to content

Add field to retrieve linked issues (closingIssuesReferences) in gh pr view <number>  #10529

Description

@vvolkgang

Describe the feature or problem you’d like to solve

Access to issues linked to Pull Requests in the Development panel. This field is available in GraphQL but not yet exposed in gh CLI. The GraphQL query to retrieve this field was shared in #7097

gh api graphql -F owner='{owner}' -F repo='{repo}' -F pr=PRNUMBER -f query='
query ($owner: String!, $repo: String!, $pr: Int!) {
	repository(owner: $owner, name: $repo) {
		pullRequest(number: $pr) {
			closingIssuesReferences(first: 100) {
				nodes {
					number
				}
			}
		}
	}
}'  --jq '.data.repository.pullRequest.closingIssuesReferences.nodes[].number'

Proposed solution

Exposing closingIssuesReferences as a field. E.g. gh view pr <number> --json closingIssuesReferences.

Activity

  1. changed the title [-]Add field to retrieve linked issues in `gh pr view`[/-] [+]Add field to retrieve linked issues (`closingIssuesReferences`) in `gh pr view <number>` [/+] on Mar 3, 2025
  2. self-assigned this
    on Mar 4, 2025
  3. jtmcg commented on Mar 4, 2025

    @jtmcg
    Contributor

    Hey @vvolkgang, seems reasonable. Thanks for the suggestion!

    Acceptance Criteria

    Given an PR references an issue to close
    when I use gh pr view <number> --json closingIssueReferences[, other fields...]
    then I get a JSON object containing an array of the closingIssuesReferences with issue numbers

    $ gh pr view 101 --json title,number,closingIssueReferences
    {
        "title": "PR title",
        "number": 101,
        "closingIssueReferences": [
            98,
            99
        ]
    }
    
  4. added
    gh-prrelating to the gh pr command
    and removed on Mar 4, 2025
  5. removed their assignment
    on Mar 4, 2025
  6. EdouardF commented on Mar 5, 2025

    @EdouardF

    Are we looking to have the opposite: gh issue view that shows which PRs would close the issue?
    Or do we have that already and I'm blind?

  7. jtmcg commented on Mar 6, 2025

    @jtmcg
    Contributor

    Are we looking to have the opposite: gh issue view that shows which PRs would close the issue? Or do we have that already and I'm blind?

    HI @EdouardF, I don't think this field exists for gh issue view, so I suppose we could add that enhancement as well. Will you make another issue for it and link this one?

  8. babakks commented on Apr 14, 2025

    @babakks
    Member

    @williammartin @iamazeem As of our discussion in the PR #10544, here's the updated acceptance criteria:

    Acceptance Criteria

    Given an PR references an issue to close
    when I use gh pr view <number> --json closingIssueReferences[, other fields...]
    then I get a JSON object containing closingIssuesReferences as an array of referenced issues with sufficient details to locate the issue:

    $ gh pr view 101 --json title,number,closingIssueReferences
    {
        "title": "PR title",
        "number": 101,
        "closingIssuesReferences": [
            {
                "number": 999,
                "id": "issue-id",
                "url": "https://github.com/...",
                "repository": {
                    "id": "repo-id",
                    "name": "repo-name",
                    "owner": {
                        "id": "owner-id",
                        "login": "owner-login"
                    }
                }
            }
        ]
    }
    

    Note that the nested structure (for repository and owner fields) is mainly to keep the schema consistent with gh repo view --json output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-prrelating to the gh pr commandhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions