diff --git a/advisors/helper/reviewer_checklist.yaml b/advisors/helper/reviewer_checklist.yaml index 58a3c87dc24df0444df513a0c85a796e08c9b225..a138c51abb0129b442f29f711c3b3e3cd38ad4d6 100644 --- a/advisors/helper/reviewer_checklist.yaml +++ b/advisors/helper/reviewer_checklist.yaml @@ -53,6 +53,12 @@ basic: condition: code-modified claim: 新增代码不包含密码、口令、token、密钥等敏感数据 explain: 提交的代码不应包含密码等敏感数据。 + Compatibility: + - + name: compatibility-check + condition: version-change + claim: 新版本能兼容老版本 + explain: spec中version版本变化,非master分支软件版本升级需考虑兼容性 customization: community: - diff --git a/advisors/review_tool.py b/advisors/review_tool.py index 89fc81c3327622c83d936bafc52c08081c2c4638..0c78a9147c8eb4c1caa2aab77bdcd86f46455658 100755 --- a/advisors/review_tool.py +++ b/advisors/review_tool.py @@ -40,6 +40,7 @@ categorizer = {'PRSubmissionSPEC':'PR提交规范', 'CleanCode':'Clean Code', 'OpenSourceCompliance':'开源合规性', 'SecurityPrivacy':'安全及隐私', + 'Compatibility':'兼容性', 'customization':'定制项'} SIGS_URL = "https://gitee.com/openeuler/community/raw/master/sig/sigs.yaml" headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW 64; rv:23.0) Gecko/20100101 Firefox/23.0'} @@ -81,17 +82,29 @@ def check_code_lang(branch): return langs, checkers -def check_license_change(branch): +def check_spec_change(branch, keyword): """ - check if spec be modified + check if value of keyword changed in spec """ - lst_files = subprocess.getoutput( + modify_files = subprocess.getoutput( "git diff --name-only --diff-filter=M remotes/origin/{}..".format(branch)) - for item in lst_files.splitlines(): + for item in modify_files.splitlines(): if item.endswith(".spec"): - lst_lines = subprocess.getoutput( - "git diff remotes/origin/{}.. ".format(branch) + item + " | grep '^+License'") - return bool(lst_lines.splitlines()) + lines = subprocess.getoutput( + "git diff remotes/origin/{0}.. {1} \ + | grep '^[+-]{2}:'".format(branch, item, keyword)) + lines_list = lines.splitlines() + if len(lines_list) != 2: + break + cur_value = "" + new_value = "" + for line in lines_list: + if line.startswith("+{}:".format(keyword)): + cur_value = line.split(":")[1].strip() + elif line.startswith("-{}:".format(keyword)): + new_value = line.split(":")[1].strip() + if cur_value != new_value: + return True return False @@ -392,7 +405,10 @@ def basic_review(cklist, branch): if not check_new_code(branch): continue elif value2['condition'] == 'license-change': - if not check_license_change(branch): + if not check_spec_change(branch, "License"): + continue + elif value2['condition'] == 'version-change': + if not check_spec_change(branch, "Version"): continue item = join_check_item(categorizer[key1], value2['claim'], value2['explain'])