diff --git a/hermetic_build/common/cli/get_changed_libraries.py b/hermetic_build/common/cli/get_changed_libraries.py index cf92cf0853..f9b3d40013 100644 --- a/hermetic_build/common/cli/get_changed_libraries.py +++ b/hermetic_build/common/cli/get_changed_libraries.py @@ -72,10 +72,6 @@ def create( baseline_config=from_yaml(baseline_generation_config_path), current_config=from_yaml(current_generation_config_path), ) - changed_libraries = config_change.get_changed_libraries() - if changed_libraries is None: - print("No changed library.") - return click.echo(",".join(config_change.get_changed_libraries())) diff --git a/hermetic_build/common/model/config_change.py b/hermetic_build/common/model/config_change.py index 7ddc338448..10edab2873 100644 --- a/hermetic_build/common/model/config_change.py +++ b/hermetic_build/common/model/config_change.py @@ -62,7 +62,6 @@ def __init__(self, commit: Commit, libraries: set[str]): class ConfigChange: - ALL_LIBRARIES_CHANGED = None def __init__( self, @@ -74,16 +73,16 @@ def __init__( self.baseline_config = baseline_config self.current_config = current_config - def get_changed_libraries(self) -> Optional[list[str]]: + def get_changed_libraries(self) -> list[str]: """ Returns a unique, sorted list of library name of changed libraries. - None if there is a repository level change, which means all libraries - in the current_config will be generated. :return: library names of change libraries. """ if ChangeType.REPO_LEVEL_CHANGE in self.change_to_libraries: - return ConfigChange.ALL_LIBRARIES_CHANGED + return [ + library.get_library_name() for library in self.current_config.libraries + ] library_names = set() for change_type, library_changes in self.change_to_libraries.items(): if change_type == ChangeType.GOOGLEAPIS_COMMIT: diff --git a/hermetic_build/common/tests/model/config_change_unit_tests.py b/hermetic_build/common/tests/model/config_change_unit_tests.py index 3abc603141..f95c4b15e2 100644 --- a/hermetic_build/common/tests/model/config_change_unit_tests.py +++ b/hermetic_build/common/tests/model/config_change_unit_tests.py @@ -39,10 +39,26 @@ def test_get_changed_libraries_with_repo_level_change_returns_all_libraries_chan ], }, baseline_config=ConfigChangeTest.__get_a_gen_config(), - current_config=ConfigChangeTest.__get_a_gen_config(), + current_config=ConfigChangeTest.__get_a_gen_config( + googleapis_commitish="", + libraries=[ + ConfigChangeTest.__get_a_library_config( + library_name="gke-backup", + gapic_configs=[ + GapicConfig(proto_path="google/cloud/gkebackup/v1") + ], + ), + ConfigChangeTest.__get_a_library_config( + library_name="test-library", + gapic_configs=[ + GapicConfig(proto_path="google/cloud/gkebackup/v1") + ], + ), + ], + ), ) self.assertEqual( - ConfigChange.ALL_LIBRARIES_CHANGED, + ["gke-backup", "test-library"], config_change.get_changed_libraries(), )