Skip to content

Commit

Permalink
fix: return a non null list
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed Nov 15, 2024
1 parent a333b07 commit 876c6fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 6 additions & 5 deletions hermetic_build/common/model/config_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, commit: Commit, libraries: set[str]):


class ConfigChange:
ALL_LIBRARIES_CHANGED = None
ALL_LIBRARIES_CHANGED = "ALL_LIBRARIES"

def __init__(
self,
Expand All @@ -74,16 +74,17 @@ 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.
A special list [ALL_LIBRARIES], will be returned 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 [ConfigChange.ALL_LIBRARIES_CHANGED]
library_names = set()
for change_type, library_changes in self.change_to_libraries.items():
if change_type == ChangeType.GOOGLEAPIS_COMMIT:
Expand Down
7 changes: 6 additions & 1 deletion hermetic_build/library_generation/cli/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def main(ctx):
show_default=True,
help="""
A list of library names that will be generated, separated by comma.
If set to `ALL_LIBRARIES`, all libraries will be generated.
The library name of a library is the value of library_name or api_shortname,
if library_name is not specified, in the generation configuration.
""",
Expand Down Expand Up @@ -157,7 +158,11 @@ def _needs_full_repo_generation(generation_config: GenerationConfig) -> bool:
def _parse_library_name_from(
includes: Optional[str], generation_config: GenerationConfig
) -> Optional[list[str]]:
if includes is None or _needs_full_repo_generation(generation_config):
if (
includes is None
or includes == "ALL_LIBRARIES"
or _needs_full_repo_generation(generation_config)
):
return None
return [library_name.strip() for library_name in includes.split(",")]

Expand Down

0 comments on commit 876c6fd

Please sign in to comment.