diff --git a/core/check_release_management.py b/core/check_release_management.py index d7a254c4a7ac93acf528f65bed293e5e0c2d32c8..8acac0ad75589c44429b0672783aa0f0d072c8ef 100644 --- a/core/check_release_management.py +++ b/core/check_release_management.py @@ -24,6 +24,7 @@ import datetime Now_path = os.path.join(os.path.split(os.path.realpath(__file__))[0]) sys.path.append(os.path.join(Now_path, "..")) from common.log_obs import log +from collections import Counter from common.common import git_repo_src class CheckReleaseManagement(object): @@ -146,7 +147,8 @@ class CheckReleaseManagement(object): if os.path.exists(file_path): with open(file_path, 'r', encoding='utf-8')as f: result = yaml.load(f, Loader=yaml.FullLoader) - all_pack_msg[yaml_path] = result['packages']['natural'] + all_pack_msg[yaml_path] = result['packages']['natural'] + \ + result['packages']['recycle'] + result['packages']['delete'] else: all_pack_msg[yaml_path] = [] return all_pack_msg @@ -243,6 +245,27 @@ class CheckReleaseManagement(object): log.error("%s format bad Because:%s" % (yaml_path, e)) raise SystemExit("May be %s has a bad format" % yaml_path) + def _check_same_pckg(self, change_file_path, yaml_msg): + """ + check the repeat pkg for the yaml file + """ + all_pkg_name = {} + for change_file in change_file_path: + pkg_name = [] + log.info("{0} repeat pkg check".format(change_file)) + for msg in yaml_msg[change_file]: + pkg_name.append(msg['name']) + dict_pkg_name = dict(Counter(pkg_name)) + repeat_pkg = [key for key, value in dict_pkg_name.items() if value > 1] + if repeat_pkg: + all_pkg_name[change_file] = repeat_pkg + if all_pkg_name: + log.error("The following packages are duplicated in the YAML files") + log.error(all_pkg_name) + return True + else: + return False + def check_pckg_yaml(self): """ check the obs_from branch_from in pckg-mgmt.yaml @@ -258,7 +281,8 @@ class CheckReleaseManagement(object): self._check_key_in_yaml(change_msg_list, change_file) error_flag1 = self._check_pkg_from(self.meta_path, change_msg_list, change_file) error_flag2 = self._check_date_time(change_msg_list, change_file) - if error_flag1 or error_flag2: + error_flag3 = self._check_same_pckg(change_file, change_yaml_msg) + if error_flag1 or error_flag2 or error_flag3: raise SystemExit("Please check your commit") if __name__ == "__main__": diff --git a/releasenode.txt b/releasenode.txt index 3f6b4c3f4590d0d9411fb62bab24c8322b65d72a..10937a8e94a85292f6c26606def65201f2affa82 100644 --- a/releasenode.txt +++ b/releasenode.txt @@ -1,3 +1,5 @@ +v1.3.6 + - add support for check the uniqueness of the package in pckg-mgmt.yaml v1.3.5: - add '-p' for cp v1.3.4: