Skip to content

Commit

Permalink
Extract all contributors into the changelog credits section in the co…
Browse files Browse the repository at this point in the history
…mpressed changelog (#184)
  • Loading branch information
wlhlm authored Dec 6, 2024
1 parent 578f27d commit 8a4ed25
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
>
# Credits
A special thanks to @Ableytner, @wlhlm, who contributed to this release!
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
1 change: 1 addition & 0 deletions src/gtnh/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
23 changes: 13 additions & 10 deletions src/gtnh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})")
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8a4ed25

Please sign in to comment.