From beadbf8e91ffbb68020e44c7dc89f94cf5fe62b8 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 27 May 2022 18:17:07 +0200 Subject: [PATCH] Improved set-version to ignore skipped deps --- tools/set_version/application.py | 4 +++- tools/set_version/version_setter_service.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/set_version/application.py b/tools/set_version/application.py index 908d2d38..f052750e 100644 --- a/tools/set_version/application.py +++ b/tools/set_version/application.py @@ -70,13 +70,15 @@ class Application(ApplicationABC): diff_paths.append(os.path.basename(os.path.dirname(file))) try: + skipped = [] for project in self._workspace.projects: if project not in diff_paths and String.convert_to_snake_case(project) not in diff_paths and not force: Console.write_line(f'Skipping {project} due to missing changes') + skipped.append(project) continue Console.write_line(f'Set dependencies {self._version_pipe.transform(version)} for {project}') - self._version_setter.set_dependencies(self._workspace.projects[project], version) + self._version_setter.set_dependencies(self._workspace.projects[project], version, skipped=skipped) if not project.startswith('cpl') and not project.startswith('unittest'): Console.write_line(f'Skipping {project}') continue diff --git a/tools/set_version/version_setter_service.py b/tools/set_version/version_setter_service.py index fcc3efaa..0ae94c93 100644 --- a/tools/set_version/version_setter_service.py +++ b/tools/set_version/version_setter_service.py @@ -1,5 +1,8 @@ import json import os +from string import ascii_letters + +from cpl_core.utils import String from cpl_core.console import Console @@ -30,7 +33,7 @@ class VersionSetterService: project_json['ProjectSettings']['Version'] = version self._write_file(file, project_json) - def set_dependencies(self, file: str, version: dict): + def set_dependencies(self, file: str, version: dict, skipped=None): project_json = self._read_file(file) dependencies = project_json['ProjectSettings']['Dependencies'] new_deps = [] @@ -40,6 +43,13 @@ class VersionSetterService: continue dep_version = dependency.split('=')[1] + dep_name = dependency.split('=')[0] + if dep_name[len(dep_name)-1] not in ascii_letters: + dep_name = dep_name[:len(dep_name)-1] + + if skipped is not None and (dep_name in skipped or String.convert_to_snake_case(dep_name) in skipped): + new_deps.append(dependency) + continue new_deps.append(dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}')) project_json['ProjectSettings']['Dependencies'] = new_deps