From bf0642789ff9696c0786bcaf96cbfaa72bdf9c0a Mon Sep 17 00:00:00 2001 From: Wilhelm Schuster Date: Fri, 8 Nov 2024 22:51:42 +0100 Subject: [PATCH] Change how mod sidedness is mentioned in the changelog Drops @Side.{CLIENT,SERVER,BOTH} in favor of a small sentence "Mod is client-side only". Bothsidedness is not mentioned at all as it is the default assumption. --- src/gtnh/cli/generate_changelog.py | 3 ++- src/gtnh/modpack_manager.py | 32 +++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/gtnh/cli/generate_changelog.py b/src/gtnh/cli/generate_changelog.py index 0435fe43..0d6c74ed 100644 --- a/src/gtnh/cli/generate_changelog.py +++ b/src/gtnh/cli/generate_changelog.py @@ -17,7 +17,8 @@ def generate_changelog(release_name: str, previous_release_name: str | None) -> raise Exception(f"Release not found {release_name}") log.debug(f"Release: {release_name}, Previous Release: {previous_release_name}") - previous_release_name = release.last_version if release.last_version and not previous_release_name else None + if not previous_release_name: + previous_release_name = release.last_version if release.last_version else None previous_release = modpack_manager.get_release(previous_release_name) if previous_release_name else None changelog = modpack_manager.generate_changelog(release, previous_release=previous_release) diff --git a/src/gtnh/modpack_manager.py b/src/gtnh/modpack_manager.py index d871292e..5978e69a 100644 --- a/src/gtnh/modpack_manager.py +++ b/src/gtnh/modpack_manager.py @@ -977,6 +977,25 @@ def generate_changelog( Generate a changelog between two releases. If the `previous_release` is None, generate it for all of history :returns: dict[mod_name, list[version_changes]] """ + + def get_pretty_side_string(side: Optional[Side]) -> str: + if side == Side.CLIENT: + return "client-side only" + if side == Side.CLIENT_JAVA9: + return "client-side Java 9+ only" + elif side == Side.SERVER: + return "server-side only" + elif side == Side.SERVER_JAVA9: + return "server-side Java 9+ only" + elif side == Side.BOTH: + return "on both sides" + elif side == Side.BOTH_JAVA9: + return "on both sides, Java 9+ only" + elif side is None: + return "unknown" + else: + return str(side) + removed_mods = set() new_mods = set() version_changes: dict[str, Tuple[Optional[ModVersionInfo], ModVersionInfo]] = {} @@ -1028,10 +1047,17 @@ def generate_changelog( changes = changelog[mod_name] if mod_name in new_mods: - changes.append(f"# New Mod - {mod_name}:{new_version}") + changes.append(f"# New Mod - {mod_name}:{new_version.version}") else: - old_version_str = f"{old_version} -->" if old_version else "" - changes.append(f"# Updated - {mod_name} - {old_version_str}{new_version}") + old_version_str = f"{old_version.version} -->" if old_version else "" + changes.append(f"# Updated - {mod_name} - {old_version_str} {new_version.version}") + + if old_version is not None and old_version.side != new_version.side: + changes.append( + f"Mod side changed from {get_pretty_side_string(old_version.side)} to {get_pretty_side_string(new_version.side)}." + ) + elif new_version.side not in [Side.BOTH, Side.BOTH_JAVA9]: + changes.append(f"Mod is {get_pretty_side_string(new_version.side)}.") for i, version in enumerate(reversed(mod_versions)): if i != 0 and version.prerelease: