[KYUUBI #5152] Check milestone and assignees when merging pull request

### _Why are the changes needed?_

- Show prompt if milestone or assignees not set when merging pull requests.
<img width="611" alt="image" src="https://github.com/apache/kyuubi/assets/1935105/4f4df661-14ab-45e4-bcfe-9050549048e6">

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests) locally before make a pull request

Closes #5152 from bowenliang123/merge-check.

Closes #5152

3a1731d40 [liangbowen] nit
20eb0e2ad [liangbowen] print
51a268e71 [liangbowen] check and print milestone and assignees of pull requests

Authored-by: liangbowen <liangbowen@gf.com.cn>
Signed-off-by: liangbowen <liangbowen@gf.com.cn>
This commit is contained in:
liangbowen 2023-08-14 09:52:18 +08:00
parent 346d7a6673
commit 875add4b79

View File

@ -30,9 +30,9 @@ import os
import re
import subprocess
import sys
from urllib.request import urlopen
from urllib.request import Request
from urllib.error import HTTPError
from urllib.request import Request
from urllib.request import urlopen
KYUUBI_HOME = os.environ.get("KYUUBI_HOME", os.getcwd())
PR_REMOTE_NAME = os.environ.get("PR_REMOTE_NAME", "apache")
@ -248,6 +248,8 @@ def main():
user_login = pr["user"]["login"]
base_ref = pr["head"]["ref"]
pr_repo_desc = "%s/%s" % (user_login, base_ref)
assignees = pr["assignees"]
milestone = pr["milestone"]
# Merged pull requests don't appear as merged in the GitHub API;
# Instead, they're closed by asfgit.
@ -276,6 +278,17 @@ def main():
print("\n=== Pull Request #%s ===" % pr_num)
print("title:\t%s\nsource:\t%s\ntarget:\t%s\nurl:\t%s\nbody:\n\n%s" %
(title, pr_repo_desc, target_ref, url, body))
if assignees is None or len(assignees)==0:
continue_maybe("Assignees have NOT been set. Continue?")
else:
print("assignees: %s" % [assignee["login"] for assignee in assignees])
if milestone is None:
continue_maybe("Milestone has NOT been set. Continue?")
else:
print("milestone: %s" % milestone["title"])
continue_maybe("Proceed with merging pull request #%s?" % pr_num)
merged_refs = [target_ref]