Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,880 changes: 1,072 additions & 808 deletions changelogs/0.1.x.md

Large diffs are not rendered by default.

2,206 changes: 1,301 additions & 905 deletions changelogs/0.2.x.md

Large diffs are not rendered by default.

462 changes: 276 additions & 186 deletions changelogs/0.3.x.md

Large diffs are not rendered by default.

1,667 changes: 1,013 additions & 654 deletions changelogs/0.4.x.md

Large diffs are not rendered by default.

2,103 changes: 1,278 additions & 825 deletions changelogs/0.5.x.md

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions scripts/reverse-changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
Copy link
Copy Markdown
Member Author

@zanieb zanieb Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by AI and validated for 0.3.x (which is nice and short).

Reverse the ordering of versions in a changelog file, i.e., when archiving a changelog.
"""

import re
import sys


def parse_changelog(content):
"""Parse the changelog content into individual version blocks."""
# Use regex to split the content by version headers
version_pattern = r"(?=## \d+\.\d+\.\d+)"
version_blocks = re.split(version_pattern, content)

# First item in the list is the header, which we want to preserve
header = version_blocks[0]
version_blocks = version_blocks[1:]

return header, version_blocks


def reverse_changelog(content):
"""Reverse the order of version blocks in the changelog."""
header, version_blocks = parse_changelog(content)

# Reverse the version blocks
reversed_blocks = version_blocks[::-1]

# Combine the header and reversed blocks
reversed_content = header + "".join(reversed_blocks)

return reversed_content


def main():
if len(sys.argv) < 2:
print("Usage: reverse-changelog.py <changelog-file>")
sys.exit(1)

# Read the input file
name = sys.argv[1]
with open(name, "r") as file:
content = file.read()

# Reverse the changelog
reversed_content = reverse_changelog(content)

# Write the output to a new file
with open(name, "w") as file:
file.write(reversed_content)

print(f"Updated {name}")


if __name__ == "__main__":
main()
Loading