Skip to content

Commit eb3e392

Browse files
Yicong-HuangIsaac
andcommitted
fix: also check the JIRA affects version when re-resolving without a fix version change
Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 2e92036 commit eb3e392

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

dev/merge_spark_pr.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,17 @@ def reconcile_jira_affects_versions(
13661366
jira_ops.update_affects_versions(issue, new_names)
13671367

13681368

1369+
def maybe_reconcile_jira_affects_versions(issue, fix_version_names, affects_available):
1370+
"""Reconcile the Affects Version/s only when they fail to precede the fix version(s).
1371+
1372+
A thin gate over ``reconcile_jira_affects_versions`` so every resolve path -- fresh
1373+
merge, backport that adds a fix version, and a re-run that adds none -- can check the
1374+
invariant without repeating ``fix_precedes_affects``.
1375+
"""
1376+
if fix_precedes_affects(fix_version_names, [v.name for v in issue.fields.versions]):
1377+
reconcile_jira_affects_versions(issue, fix_version_names, affects_available)
1378+
1379+
13691380
def get_jira_issue(prompt, default_jira_id=""):
13701381
jira_id = bold_input("%s [%s]: " % (prompt, default_jira_id))
13711382
if jira_id == "":
@@ -1449,8 +1460,13 @@ def resolve_jira_issue(
14491460
)
14501461
if all_inferred_present:
14511462
print(
1452-
"JIRA issue %s already contains all inferred fix versions; no update needed."
1453-
% issue.key
1463+
"JIRA issue %s already contains all inferred fix versions; no fix version "
1464+
"update needed." % issue.key
1465+
)
1466+
# Even when no fix version changes, the recorded Affects Version/s may still sit
1467+
# above them (e.g. a re-run of an issue whose affected version was never fixed).
1468+
maybe_reconcile_jira_affects_versions(
1469+
issue, existing_fix_version_names, affects_available
14541470
)
14551471
return
14561472
if default_fix_list:
@@ -1494,11 +1510,9 @@ def resolve_jira_issue(
14941510
print("Error setting fix version(s), try again (or leave blank and fix manually)")
14951511

14961512
# On a fresh resolve, offer to update the Affects Version/s when they sit above the fix
1497-
# version(s) just chosen; the backport path above handles the already-resolved case.
1498-
if not is_resolved and fix_precedes_affects(
1499-
fix_versions, [v.name for v in issue.fields.versions]
1500-
):
1501-
reconcile_jira_affects_versions(issue, fix_versions, affects_available)
1513+
# version(s) just chosen; the already-resolved paths handle their own cases.
1514+
if not is_resolved:
1515+
maybe_reconcile_jira_affects_versions(issue, fix_versions, affects_available)
15021516

15031517
def get_version_json(version_str):
15041518
return list(filter(lambda v: v.name == version_str, versions))[0].raw
@@ -1510,12 +1524,14 @@ def get_version_json(version_str):
15101524
jira_fix_versions = [v for v in jira_fix_versions if v["name"] not in existing_names]
15111525
if not jira_fix_versions:
15121526
print("No new fix versions selected for JIRA issue %s; no update needed." % issue.key)
1527+
maybe_reconcile_jira_affects_versions(
1528+
issue, existing_fix_version_names, affects_available
1529+
)
15131530
return
15141531
# A backport adds an earlier fix line, which usually means that line is affected too;
15151532
# offer to extend the Affects Version/s down when they miss the full fix set.
15161533
full_fix_names = existing_fix_version_names + [v["name"] for v in jira_fix_versions]
1517-
if fix_precedes_affects(full_fix_names, [v.name for v in issue.fields.versions]):
1518-
reconcile_jira_affects_versions(issue, full_fix_names, affects_available)
1534+
maybe_reconcile_jira_affects_versions(issue, full_fix_names, affects_available)
15191535
jira_ops.add_fix_versions(issue, existing_fix_versions, jira_fix_versions)
15201536
return
15211537

0 commit comments

Comments
 (0)