From 3f3d5bf927a8dbf0acee431546d0dba9d2455ea6 Mon Sep 17 00:00:00 2001 From: smileknife Date: Tue, 9 Feb 2021 10:45:55 +0800 Subject: [PATCH] review_tool:do some improvements Signed-off-by: smileknife --- advisors/review_tool.py | 1 + prow/prow_review_tool | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/advisors/review_tool.py b/advisors/review_tool.py index dccb2703..3925fa46 100755 --- a/advisors/review_tool.py +++ b/advisors/review_tool.py @@ -603,6 +603,7 @@ def prepare_env(work_dir, reuse, pr_tuple, branch): gitee_url = "https://gitee.com/{repo}.git".format(repo=repo) local_path = os.path.join(work_dir, local_repo_name(group, repo_name, pull_id)) if os.path.exists(local_path) and not reuse: + print("WARNING: %s already exist, delete it." % local_path) shutil.rmtree(local_path) if not os.path.exists(local_path): if exec_cmd(["git", "clone", gitee_url, local_path]) != 0: diff --git a/prow/prow_review_tool b/prow/prow_review_tool index 53344087..40ec9ce9 100755 --- a/prow/prow_review_tool +++ b/prow/prow_review_tool @@ -63,19 +63,23 @@ if __name__ == '__main__': return_code = subp.returncode elif args.event == 'Note Hook' and data['action'] == 'comment' \ and data['noteable_type'] == 'PullRequest': - if not data['comment']['body'].startswith("/review"): + if not data['comment']['body'].startswith("/review "): sys.exit(2) + sets_li = [] for line in data['comment']['body'].splitlines(): - if line.strip().startswith("/review"): - args = line.strip().split(' ', 1) - content = args[1] - subp = subprocess.run(["python3", get_cmd(), - "-u", data['pull_request']['html_url'], "-e", content], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - encoding="utf-8", - check=False) - return_code = subp.returncode + if line.strip().startswith("/review "): + sets = line.strip().split(maxsplit=1)[1] + sets_li.append(sets) + contents = " ".join(sets_li) + if not contents: + sys.exit(2) + subp = subprocess.run(["python3", get_cmd(), + "-u", data['pull_request']['html_url'], "-e", contents], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding="utf-8", + check=False) + return_code = subp.returncode else: print("prow_review_tool: this action type not need to process.") if return_code != 0: -- Gitee