Add issue linkage tracking to PR analysis reports using GitHub GraphQL API#5
Conversation
Co-authored-by: ChrisTimperley <523560+ChrisTimperley@users.noreply.github.com>
ChrisTimperley
left a comment
There was a problem hiding this comment.
Let's double check to see whether we can use the GraphQL to solve this problem rather than trying to parse the body of the PR.
| hasReviews: reviews.data.length > 0, | ||
| hasComments: comments.data.length > 0, | ||
| ciStatus, | ||
| linkedIssue: extractLinkedIssue(pr.body), |
There was a problem hiding this comment.
Does the GitHub GraphQL API not automatically expose this information?
There was a problem hiding this comment.
Yes, the GitHub GraphQL API has a closingIssuesReferences field that automatically exposes linked issues. This is much better than parsing PR body text as it captures both keyword-based links and manual UI linking. I'll switch to using GraphQL for this.
You're absolutely right! The GitHub GraphQL API has a |
Co-authored-by: ChrisTimperley <523560+ChrisTimperley@users.noreply.github.com>
ChrisTimperley
left a comment
There was a problem hiding this comment.
@copilot Overall, this looks great. Just fix up the linting issue (you need to format the code) and we're good to merge.
Co-authored-by: ChrisTimperley <523560+ChrisTimperley@users.noreply.github.com>
Fixed the code formatting with Prettier. The issue was a long line that needed to be broken up. All linting and formatting checks now pass. (commit: ef5c3c0) |
linkedIssuefield toPullRequestAnalysisinterface (number | null)Create utility function to extract issue numbers from PR body textREMOVEDModifyIMPROVEDGitHubService.analyzePullRequest()to detect linked issuesclosingIssuesReferencesfield instead of parsing PR bodySummary of Changes
Replaced the PR body parsing approach with GitHub's GraphQL API as suggested in the code review comments. This is much more reliable and comprehensive:
What Changed
extractLinkedIssue()function that used regex to parse PR descriptionsgetLinkedIssues()method that uses GitHub GraphQL APIanalyzePullRequest()to call the GraphQL API alongside other data fetchingBenefits of GraphQL Approach
GraphQL Query Used
The
linkedIssuefield now contains the first closing issue number from GitHub's nativeclosingIssuesReferences, ornullif no issues will be closed by the PR.All linting and formatting checks now pass successfully.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.