Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: allow unreleased-lines to be reused on other files #5593

Merged
merged 2 commits into from
Sep 14, 2024
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
66 changes: 36 additions & 30 deletions .CI/format-recent-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,43 @@
)
VERSION_REGEX = re.compile(r"^#+\s*v?\d")

# contains lines in the form of
# {commit-sha} (<{email}>\s+{date}\s+{line-no}) {line}
p = subprocess.run(
["git", "blame", "-e", "--date=iso", "../CHANGELOG.md"],
cwd=os.path.dirname(os.path.realpath(__file__)),
text=True,
check=True,
capture_output=True,
)

unreleased_lines: list[tuple[datetime, str]] = []
for line in p.stdout.splitlines():
if not line:
continue
m = LINE_REGEX.match(line)
assert m, f"Failed to match '{line}'"
content = m.group("content")

if not content:
continue
if content.startswith("#"):
if VERSION_REGEX.match(content):
break
continue # ignore lines with '#'

d = datetime.fromisoformat(m.group("date"))
d = d.astimezone(tz=timezone.utc)
content = content.replace("- ", f"- [{d.strftime('%Y-%m-%d')}] ", 1)
unreleased_lines.append((d, content))

unreleased_lines.sort(key=lambda it: it[0], reverse=True)
def get_unreleased_lines(file: str):
# contains lines in the form of
# {commit-sha} (<{email}>\s+{date}\s+{line-no}) {line}
p = subprocess.run(
["git", "blame", "-e", "--date=iso", file],
cwd=os.path.dirname(os.path.realpath(__file__)),
text=True,
check=True,
capture_output=True,
)

unreleased_lines: list[tuple[datetime, str]] = []
for line in p.stdout.splitlines():
if not line:
continue
m = LINE_REGEX.match(line)
assert m, f"Failed to match '{line}'"
content = m.group("content")

if not content:
continue
if content.startswith("#"):
if VERSION_REGEX.match(content):
break
continue # ignore lines with '#'

d = datetime.fromisoformat(m.group("date"))
d = d.astimezone(tz=timezone.utc)
content = content.replace("- ", f"- [{d.strftime('%Y-%m-%d')}] ", 1)
unreleased_lines.append((d, content))

unreleased_lines.sort(key=lambda it: it[0], reverse=True)
return unreleased_lines


unreleased_lines = get_unreleased_lines("../CHANGELOG.md")

if len(unreleased_lines) == 0:
print("No changes since last release.")
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
- Dev: Moved some responsibility away from Application into WindowManager. (#5551)
- Dev: Fixed benchmarks segfaulting on run. (#5559)
- Dev: Refactored `MessageBuilder` to be a single class. (#5548)
- Dev: Recent changes are now shown in the nightly release description. (#5553, #5554)
- Dev: Recent changes are now shown in the nightly release description. (#5553, #5554, #5593)
- Dev: The timer for `StreamerMode` is now destroyed on the correct thread. (#5571)
- Dev: Cleanup some parts of the `magic_enum` adaptation for Qt. (#5587)

Expand Down
Loading