Skip to content

Commit 75dcb96

Browse files
authored
fix: return all library names if repo-level parameter changes (#3379)
In this PR: - Return all library names as a comma-separated string if repo-level parameter changes. Fix: #3381
1 parent a333b07 commit 75dcb96

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

hermetic_build/common/cli/get_changed_libraries.py

-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ def create(
7272
baseline_config=from_yaml(baseline_generation_config_path),
7373
current_config=from_yaml(current_generation_config_path),
7474
)
75-
changed_libraries = config_change.get_changed_libraries()
76-
if changed_libraries is None:
77-
print("No changed library.")
78-
return
7975
click.echo(",".join(config_change.get_changed_libraries()))
8076

8177

hermetic_build/common/model/config_change.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def __init__(self, commit: Commit, libraries: set[str]):
6262

6363

6464
class ConfigChange:
65-
ALL_LIBRARIES_CHANGED = None
6665

6766
def __init__(
6867
self,
@@ -74,16 +73,16 @@ def __init__(
7473
self.baseline_config = baseline_config
7574
self.current_config = current_config
7675

77-
def get_changed_libraries(self) -> Optional[list[str]]:
76+
def get_changed_libraries(self) -> list[str]:
7877
"""
7978
Returns a unique, sorted list of library name of changed libraries.
80-
None if there is a repository level change, which means all libraries
81-
in the current_config will be generated.
8279
8380
:return: library names of change libraries.
8481
"""
8582
if ChangeType.REPO_LEVEL_CHANGE in self.change_to_libraries:
86-
return ConfigChange.ALL_LIBRARIES_CHANGED
83+
return [
84+
library.get_library_name() for library in self.current_config.libraries
85+
]
8786
library_names = set()
8887
for change_type, library_changes in self.change_to_libraries.items():
8988
if change_type == ChangeType.GOOGLEAPIS_COMMIT:

hermetic_build/common/tests/model/config_change_unit_tests.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,26 @@ def test_get_changed_libraries_with_repo_level_change_returns_all_libraries_chan
3939
],
4040
},
4141
baseline_config=ConfigChangeTest.__get_a_gen_config(),
42-
current_config=ConfigChangeTest.__get_a_gen_config(),
42+
current_config=ConfigChangeTest.__get_a_gen_config(
43+
googleapis_commitish="",
44+
libraries=[
45+
ConfigChangeTest.__get_a_library_config(
46+
library_name="gke-backup",
47+
gapic_configs=[
48+
GapicConfig(proto_path="google/cloud/gkebackup/v1")
49+
],
50+
),
51+
ConfigChangeTest.__get_a_library_config(
52+
library_name="test-library",
53+
gapic_configs=[
54+
GapicConfig(proto_path="google/cloud/gkebackup/v1")
55+
],
56+
),
57+
],
58+
),
4359
)
4460
self.assertEqual(
45-
ConfigChange.ALL_LIBRARIES_CHANGED,
61+
["gke-backup", "test-library"],
4662
config_change.get_changed_libraries(),
4763
)
4864

0 commit comments

Comments
 (0)