# git-cliff configuration for roba
# https://git-cliff.org/docs/configuration
#
# Generates Keep-a-Changelog-shaped entries from conventional commits.
# Used by release-plz to populate CHANGELOG.md.

[changelog]
# The leading header is preserved (release-plz only updates the
# content below it). We keep our existing header.
header = ""

# Body template: one section per release, grouped by commit type.
body = """
{% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
## [Unreleased]
{% endif -%}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}

{% for commit in commits -%}
- {{ commit.message | split(pat="\n") | first | trim }}{% if commit.breaking %} (BREAKING){% endif %}
{% endfor %}
{% endfor %}
"""

footer = ""

trim = true

[git]
# Parse conventional commits; skip ones that don't match a parser.
conventional_commits = true
filter_unconventional = true
split_commits = false
protect_breaking_commits = true

# Sort commits oldest-first within a group; sections appear in the
# order the parsers below define.
sort_commits = "oldest"
topo_order = false

# Tag pattern roba uses: v0.2.0, v0.2.1, ...
tag_pattern = "v[0-9].*"
# NB: do NOT set skip_tags / ignore_tags to "". An empty regex matches
# *every* tag, so release-plz's embedded git-cliff skips every release
# ("Skipping release: X") and emits an EMPTY changelog -- which is what
# shipped 0.2.1 with no notes (#173). Leave them unset (no skip/ignore).

# Conventional commit type -> changelog section.
# Order here is the display order in each release body.
# Commits with BREAKING get an extra "(BREAKING)" suffix via the body
# template above; the surrounding group is determined by the message
# prefix (feat -> Added, etc.). Pure docs/test/chore/style/ci land in
# their own sections; they do NOT trigger a release per release_commits
# in release-plz.toml.
commit_parsers = [
    { message = "^feat", group = "Added" },
    { message = "^fix", group = "Fixed" },
    { message = "^perf", group = "Performance" },
    { message = "^refactor", group = "Changed" },
    { message = "^docs", group = "Documentation" },
    { message = "^test", group = "Tests" },
    { message = "^chore\\(release\\)", skip = true },
    { message = "^chore\\(deps\\)", group = "Dependencies" },
    { message = "^chore", group = "Maintenance" },
    { message = "^ci", group = "CI" },
    { message = "^build", group = "Build" },
    { message = "^style", skip = true },
    { message = "^revert", group = "Reverted" },
    # Anything that didn't match above is dropped.
    { message = ".*", skip = true },
]
