Skip to content

Conversation

@Amulyam24
Copy link

This PR adds a new plugin issue-management which has commands for linking and unlinking issues to a PR.
Ref - https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue

  • The commands can be used to link an issue to a PR in the current repository or in a different repository as well as handle multiple issues
  • This is done by adding the supported keyword Fixes to the body of the PR if it doesn't already exist or by appending the issue to the existing Fixes line
  • Supported formats are issue-number and org/repo-name#issue-number

A new plugin has been added to accommodate any existing issue commands or provide flexibility to support more issue commands in the future.

Fixes #359

@netlify
Copy link

netlify bot commented Nov 25, 2025

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 216670b
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/6961f52eb596190008596be5
😎 Deploy Preview https://deploy-preview-556--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Amulyam24
Once this PR has been reviewed and has the lgtm label, please assign cjwagner for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/hook Issues or PRs related to prow's hook component labels Nov 25, 2025
@k8s-ci-robot k8s-ci-robot added area/plugins Issues or PRs related to prow's plugins for the hook component size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 25, 2025
@@ -0,0 +1,95 @@
/*
Copyright 2025 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI, current guidance is to not include the year for these copyright headers. I don't think it matters, just pointing it out to help spread awareness.

unlinkIssueRegex = regexp.MustCompile(`(?mi)^/unlink-issue((?: +(?:\d+|[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+#\d+))+)\b`)
)

type githubClient interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe there is a reason for defining this interface unless you are going to mock it for unit testing. Is that planned as a follow up? Might be good to have that included in this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I was planning that as a follow up. Sure, I'll add it to this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @stmcginnis, I explored a couple of ways on adding the UT.

At the end I feel having this interface and using the existing fake client is convenient than mocking the githubClient or using the plugins.PluginGitHubClient directly instead of githubClient as that would need mocking as well.

PTAL and let me know your thoughts!

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a small local interface is somewhat established pattern in GH-facing plugins (retitle, blunderbuss), the GH client interface surface is massive and it is often useful to have an idea of what GH operations the plugin is limited to (besides the mentioned test mock use case). I'd prefer to keep it.

@k8s-ci-robot
Copy link
Contributor

@Amulyam24: The label(s) `/label do-not-merge/work-in-progress

cannot be applied. These labels are supported:api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda, refactor, ci-short, ci-extended, ci-full. Is this label configured under labels -> additional_labelsorlabels -> restricted_labelsinplugin.yaml`?

Details

In response to this:

/label do-not-merge/work-in-progress

Adding UT

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Amulyam24
Copy link
Author

/hold

WIP: Adding UT

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 27, 2025
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 28, 2025
@Amulyam24 Amulyam24 force-pushed the issues-plugin branch 4 times, most recently from afde1e0 to c65a580 Compare December 1, 2025 09:32
@Amulyam24
Copy link
Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 1, 2025
unlinkIssueRegex = regexp.MustCompile(`(?mi)^/unlink-issue((?: +(?:\d+|[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+#\d+))+)\b`)
)

type githubClient interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Having a small local interface is somewhat established pattern in GH-facing plugins (retitle, blunderbuss), the GH client interface surface is massive and it is often useful to have an idea of what GH operations the plugin is limited to (besides the mentioned test mock use case). I'd prefer to keep it.

@petr-muller
Copy link
Contributor

I think this is pretty close, I appreciate the test coverage. Left some comment about the code structure.

@Amulyam24
Copy link
Author

Hi @petr-muller, was out for year end vacation. Most of the review comments are in place, will be working on enhancing the logic as mentioned above and push the changes this week, Thanks!

@Amulyam24 Amulyam24 force-pushed the issues-plugin branch 7 times, most recently from c48a333 to 0625b0d Compare January 9, 2026 14:13
@Amulyam24
Copy link
Author

hi @petr-muller, I have updated the logic to handle both link and unlink and tested possible scenarios. UT has been added accordingly. The PR is ready for review, PTAL, Thanks!

@Amulyam24
Copy link
Author

/retest

This PR adds a new plugin issue-management which has commands for linking and unlinking issues to a PR.

- The commands can be used to link an issue to a PR in the current repository or in a different repository as well as handle multiple issues
- This is done by adding the supported keyword Fixes to the body of the PR if it doesn't already exist or by appending the issue to the existing Fixes line
- Supported formats are issue-number and org/repo-name#issue-number

Signed-off-by: Amulyam24 <amulmek1@in.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hook Issues or PRs related to prow's hook component area/plugins Issues or PRs related to prow's plugins for the hook component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command for linking a PR to an issue

4 participants