Add filtering for PRs to match issue filtering behavior#418
Conversation
Review Summary by QodoAdd PR filtering to match issue filtering behavior
WalkthroughsDescription• Add filtering logic to PR handler matching issue filtering behavior • Support label, milestone, and custom field filtering for PRs • Ensure consistent filtering across both issue and PR handler paths • Add comprehensive test coverage for all filtering conditions Diagramflowchart LR
A["PR Handler"] --> B["Extract Filters Config"]
B --> C["Check Labels Filter"]
C --> D["Check Milestone Filter"]
D --> E["Check Other Fields Filter"]
E --> F{All Filters Pass?}
F -->|No| G["Return None"]
F -->|Yes| H["Process PR"]
File Changes1. sync2jira/upstream_pr.py
|
Code Review by Qodo
✅
📘 Rule violation ⛯ Reliability |
webbnh
left a comment
There was a problem hiding this comment.
@Bala-Sakabattula, congratulations the perfect testing coverage for this change! 🏆
However, rather than adding this code here, I think you should refactor the body of upstream_issue.handle_github_message() into a subroutine which we can call from here.
This comment was marked as outdated.
This comment was marked as outdated.
webbnh
left a comment
There was a problem hiding this comment.
It looks good, @Bala-Sakabattula. I just have some comments on the tests.
It looks like there are two tests which are now redundant and should probably be dropped. And, it looks like there a few test scenarios that you could add and/or relocate. But, I'll leave that up to you.
There are also a couple of items left over from my earlier review. Let me know if you don't want to proceed with those.
webbnh
left a comment
There was a problem hiding this comment.
@Bala-Sakabattula, congratulations the perfect testing coverage for this change! 🏆
I'm afraid I have to take back that trophy -- you missed a branch in passes_github_filters():
if key not in mapped_repos[upstream].get("sync", []):But, I'm not inclined to block the merge over that. 🙂
IFF you decide to go after that, I have one other nit (which I've "pre-resolved") for your consideration. Otherwise, I think this is good to go as soon as @ralphbean feels up to merging it.
Summary
This PR adds filtering (and other filter types) to PR handling in
upstream_pr.pyto ensure consistent filtering behavior between issues and PRs, regardless of which handler path they take.Problem
Previously, PRs were filtered inconsistently depending on which handler path they used:
u_issue.handle_github_message()withis_pr=True): PRs were filtered by labels, milestone, and other configured filters ✅u_pr.handle_github_message()): PRs were not filtered at all ❌This inconsistency meant that PRs coming through the PR handler path would bypass filtering and could create JIRA issues even when they didn't match the configured filter criteria (e.g., missing required labels).
Solution
Added the same filtering logic used in
upstream_issue.pytoupstream_pr.py'shandle_github_message()function. The filtering now supports:The same filter configuration (
config["sync2jira"]["filters"]["github"][upstream]) is used for both issues and PRs, ensuring consistent behavior.Changes
sync2jira/upstream_pr.py: Added filtering logic (lines 52-80) that mirrors the filtering inupstream_issue.pytests/test_upstream_pr.py: Added comprehensive test cases to verify all three filtering conditions work correctlyTesting
Added test cases:
test_handle_github_message_filtering: Tests that PRs are correctly filtered out when they don't match labels, milestone, or other field criteriatest_handle_github_message_filtering_passes: Tests that PRs pass through when all filters match