From 4eb8d3a5a4bddf8d7948fd5e09c4e63e27867b04 Mon Sep 17 00:00:00 2001 From: smileknife Date: Tue, 24 Nov 2020 23:43:27 +0800 Subject: [PATCH] [review_tool]default edit last list Signed-off-by: smileknife --- advisors/gitee.py | 14 ++++++++++---- advisors/helper/reviewer_checklist.yaml | 2 +- advisors/review_tool.py | 9 +++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/advisors/gitee.py b/advisors/gitee.py index c7f6d4ab..57746a96 100755 --- a/advisors/gitee.py +++ b/advisors/gitee.py @@ -15,7 +15,6 @@ This is a helper script for working with gitee.com """ -import sys import os import json import base64 @@ -146,9 +145,16 @@ class Gitee(): """ Get all comments of PR """ - url_template = "https://gitee.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments" - url = url_template.format(owner=owner, repo=repo, number=number) - return self.__get_gitee_json(url) + url_template = "https://gitee.com/api/v5/repos/{owner}/{repo}/pulls/{number}/comments"\ + "?page={page}&per_page={per_page}" + res = [] + for i in range(1, 101): + url = url_template.format(owner=owner, repo=repo, number=number, page=i, per_page=100) + comments = self.__get_gitee_json(url) + if not comments: + break + res.extend(comments) + return res def edit_pr_comment(self, owner, repo, comment_id, body): """ diff --git a/advisors/helper/reviewer_checklist.yaml b/advisors/helper/reviewer_checklist.yaml index a138c51a..b5029156 100644 --- a/advisors/helper/reviewer_checklist.yaml +++ b/advisors/helper/reviewer_checklist.yaml @@ -24,7 +24,7 @@ basic: name: PR-one-submission condition: null claim: 建议PR中只有一次提交 - explain: 如果PR中包含多次提交,建议整合成一个,保持提交记录整洁。 + explain: 如果PR中包含多次提交,建议整合成一个,保持提交记录整洁。[[Gitee work flow](https://gitee.com/openeuler/community/blob/master/zh/contributors/Gitee-workflow.md)] - name: PR-temp-check condition: new-file-add diff --git a/advisors/review_tool.py b/advisors/review_tool.py index 5d049c97..6009f9d7 100755 --- a/advisors/review_tool.py +++ b/advisors/review_tool.py @@ -614,7 +614,7 @@ def find_review_comment(user_gitee, group, repo_name, pull_id): """ review_key = "以下为 openEuler-Advisor 的 review_tool 生成审视要求清单" data = user_gitee.get_pr_comments_all(group, repo_name, pull_id) - for comment in data: + for comment in data[::-1]: if review_key in comment['body']: return comment return None @@ -630,14 +630,15 @@ def edit_review_status(args, user_gitee, group ,repo_name, pull_id): items = comment['body'].splitlines(True) need_edit = False head_len = len(CHK_TABLE_HEADER.splitlines()) + match_str = r"\[&#x[0-9A-F]+;\]" if len(args.edit) == 1 and args.edit[0] == FLAG_EDIT_ALL: need_edit = True for num in range(len(items[head_len:])): - items[head_len+num] = re.sub(r"\[.*\]", RRVIEW_STATUS[args.status], items[head_len+num]) + items[head_len+num] = re.sub(match_str, RRVIEW_STATUS[args.status], items[head_len+num]) else: for num in args.edit: if int(num) >=0 and int(num) < len(items[head_len:]): - items[head_len+num] = re.sub(r"\[.*\]", + items[head_len+num] = re.sub(match_str, RRVIEW_STATUS[args.status], items[head_len+num]) need_edit = True @@ -650,7 +651,7 @@ def main(): """ Main entrance of the functionality """ - cur_path = os.path.dirname(os.path.abspath(sys.argv[0])) + cur_path = os.path.dirname(os.path.realpath(__file__)) args = args_parser(cur_path) params = extract_params(args) if not params: -- Gitee