This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 3164ff51dd2 [SPARK-44760][INFRA] Fix list index out of range for JIRA resolution in merge_spark_pr 3164ff51dd2 is described below commit 3164ff51dd249670b8505a5ea8d361cf53c9db94 Author: Kent Yao <y...@apache.org> AuthorDate: Thu Aug 10 08:08:32 2023 -0700 [SPARK-44760][INFRA] Fix list index out of range for JIRA resolution in merge_spark_pr ### What changes were proposed in this pull request? This PR fixes list index out-of-range error for the merge_spark_pr script The error occurs when the branch we merge into does not have a jira project version. ```python >>> versions = sorted(versions, key=lambda x: x.name, reverse=True) >>> versions [<JIRA Version: name='4.0.0', id='12353359'>, <JIRA Version: name='3.5.1', id='12353495'>, <JIRA Version: name='3.5.0', id='12352848'>, <JIRA Version: name='3.4.2', id='12353368'>, <JIRA Version: name='3.3.4', id='12353505'>, <JIRA Version: name='3.3.3', id='12352932'>] >>> list(filter(lambda x: x.name.startswith(""), versions))[-1] <JIRA Version: name='3.3.3', id='12352932'> >>> list(filter(lambda x: x.name.startswith("3.2"), versions))[-1] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range ``` Unlike other archived branches or versions, v3.2.5 is missing from our JIRA. This crushes the merging scripts during JIRA resolution if branch-3.2 is chosen. ### Why are the changes needed? happy merging ### Does this PR introduce _any_ user-facing change? no, infra only change ### How was this patch tested? manually tested ```python >>> default_fix_versions = [] >>> for b in merge_branches: ... if b == "master": ... default_fix_versions.append(versions[0]) ... else: ... found = False ... for v in versions: ... if v.name.startswith(b.replace("branch-", "")): ... default_fix_versions.append(v) ... found = True ... if not found: ... print( ... "Target version for %s is not found on JIRA, it may be archived or " ... "not created. Skipping it." % b) ... Target version for branch-3.2 is not found on JIRA, it may be archived or not created. Skipping it. >>> default_fix_versions [<JIRA Version: name='4.0.0', id='12353359'>, <JIRA Version: name='3.5.0', id='12352848'>, <JIRA Version: name='3.5.1', id='12353495'>, <JIRA Version: name='3.4.2', id='12353368'>, <JIRA Version: name='3.3.3', id='12352932'>, <JIRA Version: name='3.3.4', id='12353505'>] >>> quit ``` Closes #42429 from yaooqinn/SPARK-44760. Authored-by: Kent Yao <y...@apache.org> Signed-off-by: Dongjoon Hyun <dongj...@apache.org> --- dev/merge_spark_pr.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py index 41b00b463f1..88792e77161 100755 --- a/dev/merge_spark_pr.py +++ b/dev/merge_spark_pr.py @@ -237,15 +237,6 @@ def cherry_pick(pr_num, merge_hash, default_branch): return pick_ref -def fix_version_from_branch(branch, versions): - # Note: Assumes this is a sorted (newest->oldest) list of un-released versions - if branch == "master": - return versions[0] - else: - branch_ver = branch.replace("branch-", "") - return list(filter(lambda x: x.name.startswith(branch_ver), versions))[-1] - - def resolve_jira_issue(merge_branches, comment, default_jira_id=""): asf_jira = jira.client.JIRA( {"server": JIRA_API_BASE}, basic_auth=(JIRA_USERNAME, JIRA_PASSWORD) @@ -280,14 +271,30 @@ def resolve_jira_issue(merge_branches, comment, default_jira_id=""): ) versions = asf_jira.project_versions("SPARK") + # Consider only x.y.z, unreleased, unarchived versions + versions = [ + x + for x in versions + if not x.raw["released"] and not x.raw["archived"] and re.match(r"\d+\.\d+\.\d+", x.name) + ] versions = sorted(versions, key=lambda x: x.name, reverse=True) - versions = list(filter(lambda x: x.raw["released"] is False, versions)) - # Consider only x.y.z versions - versions = list(filter(lambda x: re.match(r"\d+\.\d+\.\d+", x.name), versions)) - default_fix_versions = list( - map(lambda x: fix_version_from_branch(x, versions).name, merge_branches) - ) + default_fix_versions = [] + for b in merge_branches: + if b == "master": + default_fix_versions.append(versions[0]) + else: + found = False + for v in versions: + if v.name.startswith(b.replace("branch-", "")): + default_fix_versions.append(v) + found = True + if not found: + print( + "Target version for %s is not found on JIRA, it may be archived or " + "not created. Skipping it." % b + ) + for v in default_fix_versions: # Handles the case where we have forked a release branch but not yet made the release. # In this case, if the PR is committed to the master branch and the release branch, we --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org