diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index af91183d99f0..0dbdb7d66451 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -375,12 +375,29 @@ def check_changelog_file(self): else: self.edit_changelog() + @staticmethod + def get_need_dependency(): + template_path = Path('tools/azure-sdk-tools/packaging_tools/templates/setup.py') + with open(template_path, 'r') as fr: + content = fr.readlines() + for line in content: + if 'msrest>' in line: + target_msrest = line.strip().strip(',').strip('\'') + yield target_msrest + if 'azure-mgmt-core' in line: + target_mgmt_core = line.strip().strip(',').strip('\'') + yield target_mgmt_core + def check_ci_file_proc(self, dependency: str): def edit_ci_file(content: List[str]): new_line = f'#override azure-mgmt-{self.package_name} {dependency}' + dependency_name = dependency.split('>')[0] for i in range(len(content)): if new_line in content[i]: return + if f'azure-mgmt-{self.package_name} {dependency_name}' in content[i]: + content[i] = new_line + '\n' + return prefix = '' if '\n' in content[-1] else '\n' content.append(prefix + new_line + '\n') @@ -388,8 +405,10 @@ def edit_ci_file(content: List[str]): print_exec('git add shared_requirements.txt') def check_ci_file(self): - self.check_ci_file_proc('msrest>=0.6.21') - self.check_ci_file_proc('azure-mgmt-core>=1.3.0,<2.0.0') + # eg: target_msrest = 'msrest>=0.6.21', target_mgmt_core = 'azure-mgmt-core>=1.3.0,<2.0.0' + target_msrest, target_mgmt_core = list(self.get_need_dependency()) + self.check_ci_file_proc(target_msrest) + self.check_ci_file_proc(target_mgmt_core) def check_file(self): self.check_file_with_packaging_tool()