Skip to content

Add branch/type filters to transitions and dict-based fixVersion mapping#460

Open
istein1 wants to merge 5 commits intorelease-engineering:mainfrom
istein1:feature/branch-and-type-filtered-transitions
Open

Add branch/type filters to transitions and dict-based fixVersion mapping#460
istein1 wants to merge 5 commits intorelease-engineering:mainfrom
istein1:feature/branch-and-type-filtered-transitions

Conversation

@istein1
Copy link
Copy Markdown

@istein1 istein1 commented Apr 25, 2026

Summary

  • Add branches (glob) and issue_types filters to PR transition configs, so transitions only fire for matching branches and Jira issue types
  • Add issue_types filter support to issue transition configs
  • Support dict-based fixVersion mapping (in addition to existing string template format)
  • Add base_branch field to PR intermediary, extracted from GitHub PR payload
  • Add comprehensive tests for all new filtering and mapping logic

Test plan

  • Table-driven tests for _update_transition with issue_types filtering (7 scenarios)
  • Tests for PR branch filter match/no-match
  • Tests for PR issue type filter match/no-match
  • Test for multiple transition entries selecting the correct match
  • Table-driven tests for map_fixVersion (string template + dict lookup)
  • End-to-end test for dict-based fixVersion mapping through Issue.from_github

🤖 Generated with Claude Code

…rsion mapping, and tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@istein1 istein1 requested review from Zyzyx and ralphbean as code owners April 25, 2026 20:26
Ilanit Stein and others added 2 commits April 26, 2026 09:27
@webbnh
Copy link
Copy Markdown
Collaborator

webbnh commented Apr 27, 2026

/ok-to-test

Copy link
Copy Markdown
Collaborator

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

Hi @istein1, this looks great.

However, I've got a few items for you. I've got a concern about one log message which I think might get noisy; I have a question for Ralph; and I have a tiny coding suggestion. The rest of my comments are on the tests.

Your initial coverage looks very good, but there are some cases which I think should have additional scenarios, even though they won't increase the coverage, because they represent valid use situations, so I think we should exercise them in the tests. Also, I recommend covering your new _matches_transition_filters() function as a separate unit (and maybe with the table-driven structure, if that works).

Lastly, I think this change should include a documentation update, since you're adding a couple of new configuration features. (Here, at the minimum.)

Thanks!

Comment thread sync2jira/downstream_pr.py Outdated
Comment thread sync2jira/intermediary.py
Comment thread tests/test_downstream_issue.py Outdated
Comment on lines +1100 to +1104
if (
closed_status is not True
and issue.status == "Closed"
and existing.fields.status.name.upper() != closed_status.upper()
):
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.

@ralphbean , what is it supposed to mean when closed_status is True (i.e., when the config key 'issue_updates' includes {'transition': True})? (As it happens, nobody appears to do this except release-engineering/Sync2Jira....)

The documentation is less than clear, and my interpretation of it doesn't match my interpretation of this code.... (Should that be "if closed_status is True or the existing status doesn't match"?)

True is an acceptable value, but False is not...which is weird! And, if we're the only ones using this, now might be a good time to rescind the practice. (I think that True is supposed to be equivalent to "Closed".)

Comment thread tests/test_downstream_issue.py Outdated
Comment thread tests/test_downstream_issue.py
Comment thread tests/test_downstream_pr.py Outdated
@istein1
Copy link
Copy Markdown
Author

istein1 commented Apr 28, 2026

Thank you @webbnh,
Really appreciate your thorough review.
I'll work on addressing all the mentioned points.

Ilanit Stein and others added 2 commits May 1, 2026 17:22
- Guard noisy log in update_transition when pr_updates is absent
- Simplify base_branch extraction with dict reference instead of .get()
- Split PR filter tests into separate units for _matches_transition_filters
  and update_transition
- Add missing issue test scenarios: absent/empty issue_updates, none-match
  multiple entries, already-matching status, transition=True
- Fix misleading "cumulative" comment in issue test docstring
- Document branches, issue_types filters and dict-based fixVersion mapping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace `closed_status is not True` with `isinstance(closed_status, str)`
  to safely skip any non-string value (True, False, None, etc.)
- Show branches/issue_types as keys in the same dict in pr_updates docs
- Add test scenario for transition: False

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@istein1
Copy link
Copy Markdown
Author

istein1 commented May 4, 2026

@webbnh ,Thanks for the detailed feedback!
I’ve pushed updates to address all the comments above.
Could you take another look and let me know if these changes satisfy your requirements,
or if there’s anything else I should polish?

@webbnh
Copy link
Copy Markdown
Collaborator

webbnh commented May 4, 2026

/ok-to-test

Copy link
Copy Markdown
Collaborator

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

The code looks good; I just have a couple of thoughts on the doc changes.

* :code:`{'merge_transition': 'MODIFIED', 'branches': ['release-*', 'main'], 'issue_types': ['Bug', 'Story']}`
* Optional filters added to the same dict as the transition. ``branches`` accepts glob patterns and restricts
the transition to PRs whose target branch matches. ``issue_types`` restricts it to matching downstream JIRA
issue types. Both filters are optional and can be used independently or together.
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.

We probably shouldn't have the 'link_transition' between the two 'merge_transition' descriptions.

And, I would be inclined to have just one 'merge_transition' entry, perhaps like

    * :code:`{'merge_transition': 'MODIFIED', 'branches': ['release-*', 'main'], 'issue_types': ['Bug', 'Story']}`
        * Sync when upstream PR gets merged. Attempts to transition JIRA ticket to CUSTOM_TRANSITION on upstream merge.
        * ``branches`` and ``issue_types`` are optional and either may be omitted. ``branches`` accepts glob patterns
          and restricts the transition to PRs whose target branch matches. ``issue_types`` restricts it to matching
          downstream JIRA issue types.

If you concur, I would recommend the same for issue_updates (lines 170-173).

with a mapping (for our example it would be 'Test milestone').
* :code:`{'fixVersion': {'0.9.0': 'Product 8.1', '1.0.0': 'Product 9.0'}}`
* Dict lookup format. Maps specific upstream milestones to specific downstream fixVersions.
Milestones not present in the dict are left unchanged.
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.

You should probably tweak lines 206-207 as well. E.g.,

* You can add the following to the mapping array. This array will map an upstream field to the downstream counterpart
  using either a template or a mapping table.

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.

2 participants