aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2022-06-29 13:09:57 +0200
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2022-06-29 13:09:57 +0200
commit8deeb216cbff4e578284fc040d8f0b51e96d4b04 (patch)
tree28b262c95d47f75c870b4d0bd5899d3e1a36cc9c /.github
parent6120304537470e7e5ff94b3bf19a33787ca69083 (diff)
downloadpsn00bsdk-8deeb216cbff4e578284fc040d8f0b51e96d4b04.tar.gz
Add -g to default flags, update changelog and known bugs
Diffstat (limited to '.github')
-rw-r--r--.github/scripts/generate_release_notes.py76
1 files changed, 45 insertions, 31 deletions
diff --git a/.github/scripts/generate_release_notes.py b/.github/scripts/generate_release_notes.py
index e3fbc7f..c706191 100644
--- a/.github/scripts/generate_release_notes.py
+++ b/.github/scripts/generate_release_notes.py
@@ -8,7 +8,8 @@ from argparse import ArgumentParser, FileType
## Helpers
-VERSION_REGEX = re.compile(r"^(?:refs\/tags\/)?(?:v|ver|version|release)? *(.*)")
+VERSION_REGEX = re.compile(r"^(?:refs\/tags\/)?(?:v|ver|version|release)? *(.*)")
+TEXT_WRAP_REGEX = re.compile(r"(?<!\n)[ \t]*?\n[ \t]*(?!\n)", re.MULTILINE)
def parse_date(date):
if isinstance(date, struct_time):
@@ -19,11 +20,27 @@ def parse_date(date):
def normalize_version(version):
return VERSION_REGEX.match(version.lower()).group(1)
+def unwrap_text(text):
+ return TEXT_WRAP_REGEX.sub(" ", text.strip())
+
+def deduplicate_authors(authors):
+ _authors = []
+ folded = []
+
+ for name in authors:
+ if (fold := name.lower()) in folded:
+ continue
+
+ _authors.append(name)
+ folded.append(fold)
+
+ _authors.sort()
+ return _authors
+
## Changelog parser
-BLOCK_REGEX = re.compile(r"^#{2,}[ \t]*([0-9]{4}-[0-9]{2}-[0-9]{2})(?:[:\- \t]+(.+?))?$", re.MULTILINE)
-AUTHOR_REGEX = re.compile(r"^([A-Za-z0-9_].*?)[ \t]*:.*?$", re.MULTILINE)
-FIRST_VERSION = "initial"
+BLOCK_REGEX = re.compile(r"^#{2,}[ \t]*([0-9]{4}-[0-9]{2}-[0-9]{2})(?:[:\- \t]+(.*?))?$", re.MULTILINE)
+AUTHOR_REGEX = re.compile(r"^([A-Za-z0-9_].*?)[ \t]*:.*?$", re.MULTILINE)
def parse_authors(block):
# [ _crap, author, body, author, body, ... ]
@@ -35,13 +52,10 @@ def parse_authors(block):
authors = {}
for i in range(1, len(items), 2):
name, body = items[i:i + 2]
-
- name = name.strip()
- body = body.strip()
- if name not in authors:
+ if (name := name.strip()) not in authors:
authors[name] = ""
- authors[name] += body
+ authors[name] += body.strip()
return authors
@@ -49,21 +63,18 @@ def parse_blocks(changelog):
# [ _crap, date, version, body, date, version, body, ... ]
items = BLOCK_REGEX.split(changelog.strip())
- # Iterate over all blocks from bottom to top (i.e. oldest first).
- last_version = FIRST_VERSION
+ # Iterate over all blocks from bottom to top (i.e. oldest first) and group
+ # them by the version number of the block they precede.
+ blocks = []
for i in range(len(items), 1, -3):
date, version, body = items[i - 3:i]
- # If no version is present in the header, assume it's the same as the
- # previous block's version.
- if version:
- version = normalize_version(version)
- last_version = version
- else:
- version = last_version
+ blocks.append(( parse_date(date), parse_authors(body) ))
- yield parse_date(date), version, parse_authors(body)
+ if version:
+ yield normalize_version(version), tuple(blocks)
+ blocks = []
## Release notes generation
@@ -74,9 +85,8 @@ VERSION_TEMPLATE = """New in version **{version}** (contributed by {authors}):
"""
NOTES_TEMPLATE = """{notes}
--------------------------------------------------------
-_These notes have been generated automatically._
-_See the changelog or commit history for more details._
+------------------------------------------------------------------------------------------------------
+_These notes have been generated automatically. See the changelog or commit history for more details._
"""
NO_VERSIONS_TEMPLATE = "No information available about this release."
@@ -87,8 +97,10 @@ def generate_notes(versions):
notes = ""
for version, ( authors, changes ) in versions.items():
- _authors = list(set(authors))
- _authors.sort()
+ if not changes:
+ continue
+
+ _authors = deduplicate_authors(authors)
_authors = map(AUTHOR_LINK_TEMPLATE.format, _authors)
notes += VERSION_TEMPLATE.format(
@@ -100,7 +112,7 @@ def generate_notes(versions):
if not notes:
notes = NO_VERSIONS_TEMPLATE
- return NOTES_TEMPLATE.format(notes = notes.strip())
+ return NOTES_TEMPLATE.format(notes = unwrap_text(notes))
## Main
@@ -155,19 +167,21 @@ def main():
# merging all changes and authors for each version.
versions = {}
- for date, version, authors in parse_blocks(changelog):
- # Apply version and date filters.
+ for version, blocks in parse_blocks(changelog):
if version_list and (version not in version_list):
continue
- if date < args.from_date or date > args.to_date:
- continue
if version not in versions:
versions[version] = [], []
_authors, _changes = versions[version]
- _authors.extend(authors.keys())
- _changes.extend(authors.values())
+
+ for date, authors in blocks:
+ if date < args.from_date or date > args.to_date:
+ continue
+
+ _authors.extend(authors.keys())
+ _changes.extend(authors.values())
notes = generate_notes(versions)