Option C Tools
Loading...
Searching...
No Matches
oct.git.changelog Namespace Reference

Classes

class  ChangelogEntry

Functions

list[ChangelogEntrycollect_changelog_entries (Path repo_root, str|None since_ref=None)
str format_changelog (list[ChangelogEntry] entries, str|None version=None)
dict changelog_to_json (list[ChangelogEntry] entries, str|None version=None)

Variables

dict _TYPE_TO_SECTION
list _SECTION_ORDER

Detailed Description

Purpose
-------
Generate a Keep a Changelog formatted changelog from Conventional Commits
history (Phase 4E — G-E1).

Responsibilities
----------------
- Parse git log output into structured changelog entries.
- Map Conventional Commits types to Keep a Changelog sections.
- Render changelog in Markdown and JSON formats.

Diagnostics
-----------
Domain: GIT
Levels:
    L2 — changelog generation lifecycle
    L3 — entry collection details
    L4 — per-commit parsing trace

Contracts
---------
- ``collect_changelog_entries`` returns an empty list on fresh repos.
- ``format_changelog`` always returns valid Markdown.
- Non-conventional commits are silently skipped (never raises).

Function Documentation

◆ changelog_to_json()

dict oct.git.changelog.changelog_to_json ( list[ChangelogEntry] entries,
str | None version = None )
Return structured dict for ``--json`` output.

Definition at line 205 of file changelog.py.

◆ collect_changelog_entries()

list[ChangelogEntry] oct.git.changelog.collect_changelog_entries ( Path repo_root,
str | None since_ref = None )
Read git log, parse each conventional commit, return entries.

Non-conventional commits are silently skipped. If *since_ref* is
``None``, the latest tag is used; if no tags exist, the entire
history is scanned.

Definition at line 88 of file changelog.py.

◆ format_changelog()

str oct.git.changelog.format_changelog ( list[ChangelogEntry] entries,
str | None version = None )
Render entries in Keep a Changelog format.

Groups entries by section in the canonical order. If *version* is
provided, the header uses ``## [version] - YYYY-MM-DD``; otherwise
``## [Unreleased]``.

Definition at line 161 of file changelog.py.

Variable Documentation

◆ _SECTION_ORDER

list oct.git.changelog._SECTION_ORDER
protected
Initial value:
1= [
2 "Added",
3 "Changed",
4 "Fixed",
5 "Security",
6 "Documentation",
7]

Definition at line 58 of file changelog.py.

◆ _TYPE_TO_SECTION

dict oct.git.changelog._TYPE_TO_SECTION
protected
Initial value:
1= {
2 "feat": "Added",
3 "fix": "Fixed",
4 "docs": "Documentation",
5 "refactor": "Changed",
6 "perf": "Changed",
7 "sec": "Security",
8}

Definition at line 48 of file changelog.py.