nchammas commented on code in PR #58288:
URL: https://github.com/apache/spark/pull/58288#discussion_r3866910469


##########
dev/merge_spark_pr.py:
##########
@@ -1179,6 +1285,56 @@ def reconcile_jira_components(issue, title_components):
     jira_ops.update_components(issue, new_names)
 
 
+def reconcile_jira_affects_versions(issue, fix_version_names, 
affects_available):
+    """Prompt the committer to update the JIRA Affects Version/s during a 
merge.
+
+    Meant for the case the caller gates on with ``fix_precedes_affects``: the 
affected
+    floor sits above the earliest fix, so a fixed release is not admitted as 
affected.
+    Mirrors the Fix Version prompt but targets ``issue.fields.versions``: it 
shows the
+    current Affects Version/s and the fix version(s) being set, offers a 
default
+    inferred from the fix version(s) via ``suggest_affects_versions``, then 
reads a
+    comma-separated entry validated against ``affects_available`` (all 
unarchived
+    versions, since an affected version may be released) with a retry loop. A 
blank
+    entry accepts the suggested default; otherwise the parsed versions replace 
the
+    current ones (through ``jira_ops`` so a dry run only logs the intended 
write).
+    """
+    current_names = [v.name for v in issue.fields.versions]
+    suggested = [
+        n
+        for n in suggest_affects_versions(fix_version_names, current_names)
+        if n in affects_available
+    ]
+    if not suggested:
+        return
+    default_str = ",".join(suggested)
+    print()
+    print("=" * 80)
+    print(
+        "JIRA %s Affects Version/s %s do not cover the fix version(s) %s."
+        % (issue.key, current_names if current_names else "(none)", 
fix_version_names)
+    )
+    print("=" * 80)
+    while True:
+        try:
+            raw = bold_input("Enter comma-separated affects version(s) [%s]: " 
% default_str)
+            if raw.strip() == "":
+                raw = default_str
+            new_names, valid = parse_affects_versions_input(raw, 
affects_available)
+            if valid and new_names:
+                break
+            print(
+                "Specified version(s) [%s] not found in the available 
versions, try "
+                "again (or leave blank to accept the suggestion)." % ", 
".join(new_names)
+            )

Review Comment:
   Couldn't we simplify this by giving the user a list of potential versions to 
choose from by index? Like how we do with the Assignee. Then we avoid needing 
to loop, parse, or validate their manually inputted versions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to