diff --git a/core/check_release_management.py b/core/check_release_management.py index 5414641a9ed0510678619e0a167a0696dd4caece..402b498f8302dd50a06655b8f091abc99db657b0 100644 --- a/core/check_release_management.py +++ b/core/check_release_management.py @@ -767,7 +767,7 @@ class CheckReleaseManagement(object): check the key and brach from in your yaml compliance with rules """ error_flag = False - keylist = ['source_dir', 'obs_from', 'name', 'destination_dir', 'obs_to', 'date', 'quality_level'] + keylist = ['source_dir', 'obs_from', 'name', 'destination_dir', 'obs_to', 'date', 'quality_level', 'c_dir'] for branch,info in change_info.items(): if info: log.info("branch:{} yaml key check".format(branch)) @@ -914,6 +914,25 @@ class CheckReleaseManagement(object): raise SystemExit("ERROR: Please check your PR") return change_infos + def _check_obs_to_dir(self, change_infos): + ''' + compare with obs_to and branch dir + ''' + error_flag = False + log.info("obs_to and relase branch dir check") + for branch,pkgs in change_infos.items(): + for pkg in pkgs: + if 'Epol' in pkg['obs_to']: + if pkg['c_dir'] != 'epol': + log.error("pkg:{} obs_to is not adapt release-management branch dir {}".format(pkg['name'], pkg['c_dir'])) + error_flag = True + else: + if pkg['c_dir'] == 'epol': + log.error("pkg:{} obs_to is not adapt release-management branch dir {}".format(pkg['name'], pkg['c_dir'])) + error_flag = True + self.job_result['check_package_add'] = 'failed' + return error_flag + def _check_internal_move(self, old_msg, new_msg): ''' compare with old and new yaml msg, make sure internal move pkgs not repeat @@ -1013,7 +1032,10 @@ class CheckReleaseManagement(object): if os.path.exists(release_path): with open(release_path, 'r', encoding='utf-8') as f: result = yaml.load(f, Loader=yaml.FullLoader) - all_branch_pkgs.extend(result['packages']) + for pkg in result['packages']: + pkg['c_dir'] = c_dir + all_branch_pkgs.append(pkg) + # all_branch_pkgs.extend(result['packages']) return all_branch_pkgs def _get_master_yaml_msg(self, path_list, manage_path): @@ -1076,7 +1098,7 @@ class CheckReleaseManagement(object): comment_tips.append("1)本次构建号为{2}/{1},点击可查看构建详情: #{1}\n".format(build_url,job_id,job_name)) comment_tips.append("2)若有检查失败项目,请勿合入") comment_tips.append("3)若您对如何创建提交PR有疑问," \ - "可参考" \ + "可参考" \ "开发者提交PR指导手册") details = { 'check_yaml_format':"检查yaml格式是否正确", @@ -1136,11 +1158,12 @@ class CheckReleaseManagement(object): self._check_key_in_yaml_new(change_infos) self._check_valid_release_branch(change_infos) date_flag = self._check_pkg_date(change_infos) + obs_to_flag = self._check_obs_to_dir(change_infos) branch_flag = self._check_pkg_branch_exist(change_infos, check_type='other') correct_from, error_from = self._check_pkg_from_new(self.meta_path, change_infos) error_flag_add = self._check_pkg_parent_from(change_infos, correct_from, error_from, add_infos) error_flag_del = self._check_pkg_delete_new(self.meta_path, change_delete_infos) - if error_flag_add or error_flag_del or date_flag or branch_flag: + if error_flag_add or error_flag_del or date_flag or branch_flag or obs_to_flag: self._comment_to_pr() raise SystemExit("Please check your commit") if change_file: