Skip to content

Commit

Permalink
Change how mod sidedness is mentioned in the changelog
Browse files Browse the repository at this point in the history
Drops <mod-version>@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.
  • Loading branch information
wlhlm committed Nov 10, 2024
1 parent 5cd71a4 commit bf06427
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/gtnh/cli/generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 29 additions & 3 deletions src/gtnh/modpack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = {}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit bf06427

Please sign in to comment.