Skip to content

Automatically link backport PRs to issues in Development - #95

Merged
stianst merged 2 commits into
keycloak:mainfrom
mabartos:KC-94
Nov 13, 2026
Merged

stianst merged 2 commits into
keycloak:mainfrom
mabartos:KC-94

Conversation

@mabartos

Copy link
Copy Markdown
Member
  • Closes Automatically link backport PRs to issues in Development #94
  • Automatically link release-branch backport PRs to referenced issues in Development
  • Handle opened, edited, and reopened PRs using closing references in their descriptions
  • Add focused tests for linking and reference parsing
  • Automatic linking requires GitHub App permission to link PRs to issues.

cc: @stianst

@mabartos
mabartos marked this pull request as ready for review October 14, 2026 10:53
@stianst stianst self-assigned this Oct 14, 2026
@stianst
stianst self-requested a review October 14, 2026 12:30

@stianst stianst left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should not use the repository.mainRepository config option, but rather only link PRs to issue if they are in the same repo. Effectively only support Closes/fixes #issue, not the cross-repo approach.

Please extract the part that parses the body to pull out fixed issues into a separate utility, and also provide some unit test for that.

@mabartos

Copy link
Copy Markdown
Member Author

@stianst Should be ready for another review.

@stianst stianst left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add some more logging; when a PR is linked to an issue do a info level log that states what PR was linked to which issue.

When there is an error (make sure you catch all exceptions) log an error and include the PR that was causing issues. This makes it easier to debug the problem, but also allows to manually update the issue/PR links if we want to fix it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The GraphQL linking integration is tested only with mocked clients, leaving installation-authenticated webhook injection, linking to closed issues, and deployed App permissions unverified against GitHub.

No open issues 🎉

What changed in this PR

Automates Development-section links between release-branch backport PRs and referenced issues, addressing #94 and reducing manual tracking.

Changes:

  • Adds GraphQL-based linking for open PRs targeting release/* when opened, edited, or reopened.
  • Parses and deduplicates closing references from PR descriptions, accepting shorthand, repository-qualified references, and issue URLs within the same repository.
  • Adds focused handler and parser tests, plus documentation of the feature’s behavior and scope.
File Description
src/​test/​java/​org/​keycloak/​gh/​bot/​utils/​PullRequestParserTest.java Tests reference formats, repository filtering, deduplication, and invalid numbers.
src/​test/​java/​org/​keycloak/​gh/​bot/​LinkBackportPRsTest.java Tests event handling, linking eligibility, missing issues, and GraphQL errors.
src/​main/​java/​org/​keycloak/​gh/​bot/​utils/​PullRequestParser.java Extracts valid, unique closing references for the current repository.
src/​main/​java/​org/​keycloak/​gh/​bot/​LinkBackportPRs.java Handles PR events and links eligible backports to issues through GraphQL.
README.md Documents supported events, reference formats, and linking scope.

Review effort: Balanced

Closes keycloak#94

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
Signed-off-by: Martin Bartoš <mabartos@redhat.com>
@stianst
stianst merged commit 0149281 into keycloak:main Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically link backport PRs to issues in Development

3 participants