feat/configurable-groups #2

Merged
marc merged 2 commits from feat/configurable-groups into main 2024-11-12 04:04:54 +00:00
2 changed files with 11 additions and 1 deletions
Showing only changes of commit 13d132708b - Show all commits

View file

@ -37,9 +37,13 @@ def build_changelog(config: Config, commits: list[Commit]) -> str:
if not selected_commits:
continue
selected_commits.sort(key=lambda c: c.committed_at, reverse=True)
changelog_lines.append(f"\n## {group.label}\n")
for commit in selected_commits:
changelog_lines.append(f"- {commit.subject} ({commit.author})")
changelog_lines.append(
f"- {commit.subject} ({commit.committed_at.date()}, {commit.author})"
)
return "\n".join(changelog_lines)

View file

@ -2,6 +2,7 @@ import subprocess
import dataclasses
import json
import functools
import datetime
@dataclasses.dataclass
@ -11,6 +12,7 @@ class Commit:
short_hash: str
body: str
subject: str
committed_at: datetime.datetime
@functools.cache
@ -21,6 +23,7 @@ def _get_commit_format() -> str:
"short_hash": "%h",
"body": "%b",
"subject": "%s",
"committed_at": "%ct",
}
return json.dumps(log_format)
@ -48,6 +51,9 @@ def log(from_ref: str, to_ref: str) -> list[Commit]:
short_hash=commit_parsed["short_hash"],
subject=commit_parsed["subject"],
body=commit_parsed["body"],
committed_at=datetime.datetime.fromtimestamp(
int(commit_parsed["committed_at"])
),
)
)