From 8a4ed25e68b043931b88868c431e5ddb23f4a961 Mon Sep 17 00:00:00 2001 From: Wilhelm Schuster Date: Fri, 6 Dec 2024 18:05:11 +0100 Subject: [PATCH] Extract all contributors into the changelog credits section in the compressed changelog (#184) --- ...changelog from 2.7.0-RC-2 to 2.7.0-RC-3.md | 2 +- src/gtnh/defs.py | 1 + src/gtnh/utils.py | 23 +++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/releases/changelogs/changelog from 2.7.0-RC-2 to 2.7.0-RC-3.md b/releases/changelogs/changelog from 2.7.0-RC-2 to 2.7.0-RC-3.md index 2f081341..76dd91ac 100644 --- a/releases/changelogs/changelog from 2.7.0-RC-2 to 2.7.0-RC-3.md +++ b/releases/changelogs/changelog from 2.7.0-RC-2 to 2.7.0-RC-3.md @@ -66,4 +66,4 @@ > # Credits -A special thanks to @Ableytner, @wlhlm, who contributed to this release! \ No newline at end of file +Special thanks to @Ableytner, @Alexdoru, @Cleptomania, @Connor-Colenso, @FourIsTheNumber, @Glease, @ah-OOG-ah, @kurrycat2004, @lordIcocain, @serenibyss, @slprime, @wlhlm, for their code contributions listed above, and to everyone else who helped, including all of our beta testers! <3 \ No newline at end of file diff --git a/src/gtnh/defs.py b/src/gtnh/defs.py index 7ba6a599..a8d6c56d 100644 --- a/src/gtnh/defs.py +++ b/src/gtnh/defs.py @@ -222,6 +222,7 @@ def __init__(self, name: str, version: str, is_new: bool) -> None: self.version: str = version self.is_new: bool = is_new self.changes: List[str] = [] + self.contributors: Set[str] = set() self.new_contributors: List[str] = [] self.oldest_link_version = "" self.newest_link_version = "" diff --git a/src/gtnh/utils.py b/src/gtnh/utils.py index a972520c..1fac0a3f 100755 --- a/src/gtnh/utils.py +++ b/src/gtnh/utils.py @@ -184,6 +184,9 @@ def compress_changelog(file_path: Path) -> None: current_version = line[4:-1] elif line.startswith(">* "): if in_changes_mode: + match = re.search(r"by (@\S+) in http.*$", line) + if match: + current_entry.contributors.add(match.group(1)) current_entry.changes.append(f"{line[3:]} ({current_version})") else: current_entry.new_contributors.append(f"{line[3:]} ({current_version})") @@ -203,9 +206,10 @@ def compress_changelog(file_path: Path) -> None: with open(file_path, "w") as file: for line in initial_lines: file.write(line + "\n") - new_contributors = set() + contributors = set() lines = [] for ent in entries: + if ent.is_new: lines.append("# New Mod - " + ent.name + " (" + ent.version + ")\n") else: @@ -242,21 +246,20 @@ def compress_changelog(file_path: Path) -> None: lines.append("> * " + ch + "\n") lines.append(">\n") - if ent.new_contributors: - # file.write(">## New Contributors\n") - for nc in ent.new_contributors: - name = nc.split(" ")[0] - if name.startswith("@"): - new_contributors.add(name) - # file.write(">\n") + if ent.contributors: + contributors.update(ent.contributors) lines.append("\n") if len(lines) == 0: lines.append("# Nothing changed this time!") - elif len(new_contributors) > 0: + elif len(contributors) > 0: lines.append("# Credits\n") lines.append( - f"A special thanks to {', '.join(sorted(list(new_contributors)))}, who contributed to this release!" + ( + f"Special thanks to {', '.join(sorted(list(contributors)))}, " + "for their code contributions listed above, and to everyone else who helped, " + "including all of our beta testers! <3" + ) ) for line in lines: