Support for discovering referenced and to-be-closed issues from a PR

There doesn’t seem to be an API endpoint (or GraphQL query at least) for what issues are referenced or will be closed when a PR is merged. Am I missing something?


I haven’t tested this, but you may be able to go through the timelineItems connection and look for CrossReferencedEvent objects with the willClose field set to true.

Let me know if that helps!

That was my initial though as well, but unless I’m mistaking the CrossReferencedEvent willClose flag is called willCloseTarget. In the cross reference the PR is the source and the issue is the target so the flag is actually false.

Perhaps a willCloseSource? :pray:

Yes, you’re correct, the field is called willCloseTarget.

Unfortunately, the CrossReferencedEvent object is only added to the timeline of the target, not of the source. So I was mistaken, there isn’t a way to determine the issues that a PR would close via the API. My apologies.

How about after the fact? The Issue in GitHub has a “Fixed by #nnn” status implying that there is an association to a PR from the Issue’s perspective. The timeline will even show the reference and I’m assuming that the merge of the PR invokes an automatic close of the issue referenced in the PR. 

I would like to be able to trace back from the issue the PR that closed it similar to how the GitHub UI does it?

I’ve grabbed all of the events to the issue and the Events help page indicates that with the close event:

When the commit_id is present, it identifies the commit that closed the issue using "closes / fixes #NN" syntax.

But I have found that the commit_id is not populated. Instead, occassionally, there is a reference with a commit ID following the close event. But this doesn’t happen all the time.

So what is being used by the UI to show the status that the issue was closed by a particular PR?