Skip to content

Commit 593e957

Browse files
pan3793jongyoul
authored andcommitted
[ZEPPELIN-6089][INFRA][FOLLOWUP] Consider multiple digits when comparing version numbers
### What is this PR for? This PR fixes some issues in the `dev/merge_zeppelin_pr.py` to make it smarter in suggesting "backport branch" and "fixed versions". 1. improve the `x.y.z` version comparing For versions: `["0.9.1", "0.10.1", "0.11.3", "0.12.0"]` Previously, it was a simple string comparison, so the desc sorted result is `["0.9.1", "0.12.0", "0.11.3", "0.10.1"]`; this PR changes it by interpreting each x, y, z as an int value and comparing sequence, thus the desc sorted result is `["0.12.0", "0.11.3", "0.10.1", "0.9.1"]` 2. improve the `branch-x.y` branch comparing similar to 1, `branch-0.10` is higher than `branch-0.9` 3. dedup `found_versions` before ``` Enter comma-separated fix version(s) [0.12.0,0.12.0]: ``` after ``` Enter comma-separated fix version(s) [0.12.0]: ``` ### What type of PR is it? Improvement ### Todos ### What is the Jira issue? ZEPPELIN-6089 ### How should this be tested? Manually tested by using the updated script to merge three PRs. ``` $ dev/merge_zeppelin_pr.py git rev-parse --abbrev-ref HEAD Which pull request would you like to merge? (e.g. 34): 4850 === JIRA ZEPPELIN-6112 === Summary Unable to serve documentation website Assignee Chan Ho Lee Status Open Url https://issues.apache.org/jira/browse/ZEPPELIN-6112 Affected [] === Pull Request #4850 === title [ZEPPELIN-6112] Fix running documentation website server source tbonelee/fix-docs target master url https://api.github.com/repos/apache/zeppelin/pulls/4850 Proceed with merging pull request #4850? (y/N): y git config --get user.name git config --get user.email Pull request #4850 merged! Merge hash: aa5abd5 git fetch apache master remote: Enumerating objects: 1, done. remote: Counting objects: 100% (1/1), done. remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (1/1), 1.45 KiB | 742.00 KiB/s, done. From github.com:apache/zeppelin * branch master -> FETCH_HEAD 4aff03b..aa5abd5 master -> apache/master Would you like to pick aa5abd5 into another branch? (y/N): y Enter a branch name [branch-0.12]: git fetch apache branch-0.12:PR_TOOL_PICK_PR_4850_BRANCH-0.12 From github.com:apache/zeppelin * [new branch] branch-0.12 -> PR_TOOL_PICK_PR_4850_BRANCH-0.12 git checkout PR_TOOL_PICK_PR_4850_BRANCH-0.12 Switched to branch 'PR_TOOL_PICK_PR_4850_BRANCH-0.12' git cherry-pick -sx aa5abd5 Pick complete (local ref PR_TOOL_PICK_PR_4850_BRANCH-0.12). Push to apache? (y/N): y git push apache PR_TOOL_PICK_PR_4850_BRANCH-0.12:branch-0.12 Enumerating objects: 19, done. Counting objects: 100% (19/19), done. Delta compression using up to 10 threads Compressing objects: 100% (10/10), done. Writing objects: 100% (10/10), 4.27 KiB | 4.27 MiB/s, done. Total 10 (delta 7), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (7/7), completed with 7 local objects. remote: remote: GitHub found 197 vulnerabilities on apache/zeppelin's default branch (18 critical, 68 high, 87 moderate, 24 low). To find out more, visit: remote: https://github.com/apache/zeppelin/security/dependabot remote: To github.com:apache/zeppelin.git 3cadfe1..671eca8 PR_TOOL_PICK_PR_4850_BRANCH-0.12 -> branch-0.12 git rev-parse PR_TOOL_PICK_PR_4850_BRANCH-0.12 Restoring head pointer to ZEPPELIN-6089-followup git checkout ZEPPELIN-6089-followup Switched to branch 'ZEPPELIN-6089-followup' git branch Deleting local branch PR_TOOL_PICK_PR_4850_BRANCH-0.12 git branch -D PR_TOOL_PICK_PR_4850_BRANCH-0.12 Pull request #4850 picked into branch-0.12! Pick hash: 671eca8 Would you like to pick aa5abd5 into another branch? (y/N): n Would you like to update an associated JIRA? (y/N): y Enter a JIRA id [ZEPPELIN-6112]: === JIRA ZEPPELIN-6112 === Summary Unable to serve documentation website Assignee Chan Ho Lee Status Open Url https://issues.apache.org/jira/browse/ZEPPELIN-6112 Affected [] Check if the JIRA information is as expected (y/N): y Enter comma-separated fix version(s) [0.12.0]: === JIRA ZEPPELIN-6112 === Summary Unable to serve documentation website Assignee Chan Ho Lee Status Resolved Url https://issues.apache.org/jira/browse/ZEPPELIN-6112 Affected [] Fixed ['0.12.0'] Successfully resolved ZEPPELIN-6112 with fixVersions=['0.12.0']! ``` ### Screenshots (if appropriate) ### Questions: * Does the license files need to update? No. * Is there breaking changes for older versions? No. * Does this needs documentation? No. Closes #4851 from pan3793/ZEPPELIN-6089-followup. Signed-off-by: Jongyoul Lee <[email protected]> (cherry picked from commit 7fe18f4) Signed-off-by: Jongyoul Lee <[email protected]>
1 parent 82e85ae commit 593e957

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dev/merge_zeppelin_pr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def resolve_jira_issue(merge_branches, comment, default_jira_id=""):
270270
for x in versions
271271
if not x.raw["released"] and not x.raw["archived"] and re.match(r"\d+\.\d+\.\d+", x.name)
272272
]
273-
versions = sorted(versions, key=lambda x: x.name, reverse=True)
273+
versions = sorted(versions, key=lambda x: list(map(int, x.name.split('.'))), reverse=True)
274274

275275
default_fix_versions = []
276276
for b in merge_branches:
@@ -288,7 +288,8 @@ def resolve_jira_issue(merge_branches, comment, default_jira_id=""):
288288
# For example, assuming
289289
# versions = ['4.0.0', '3.5.1', '3.5.0', '3.4.2', '3.3.4', '3.3.3']
290290
# we've found two candidates for branch-3.5, we pick the last/smallest one
291-
default_fix_versions.append(found_versions[-1])
291+
if found_versions[-1] not in default_fix_versions:
292+
default_fix_versions.append(found_versions[-1])
292293
else:
293294
print_error(
294295
"Target version for %s is not found on JIRA, it may be archived or "
@@ -538,8 +539,7 @@ def main():
538539

539540
branches = http_get("%s/branches" % GITHUB_API_BASE)
540541
branch_names = list(filter(lambda x: x.startswith("branch-"), [x["name"] for x in branches]))
541-
# Assumes branch names can be sorted lexicographically
542-
branch_names = sorted(branch_names, reverse=True)
542+
branch_names = sorted(branch_names, key=lambda x: list(map(int, x.removeprefix("branch-").split('.'))), reverse=True)
543543
branch_iter = iter(branch_names)
544544

545545
pr_num = bold_input("Which pull request would you like to merge? (e.g. 34): ")

0 commit comments

Comments
 (0)