# git-cliff configuration — https://git-cliff.org
# Generates CHANGELOG.md from Conventional Commits

[changelog]
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
"""
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 }}\n
{% for commit in commits %}\
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
footer = """
{% for release in releases %}\
    {% if release.version %}\
        {% if release.previous.version %}\
            [{{ release.version | trim_start_matches(pat="v") }}]: \
                https://github.com/denisotree/tuitab/compare/{{ release.previous.version }}...{{ release.version }}
        {% else %}\
            [{{ release.version | trim_start_matches(pat="v") }}]: \
                https://github.com/denisotree/tuitab/releases/tag/{{ release.version }}
        {% endif %}\
    {% else %}\
        [unreleased]: https://github.com/denisotree/tuitab/compare/{{ release.previous.version }}...HEAD
    {% endif %}\
{% endfor %}
"""
trim = true

[git]
conventional_commits = true
filter_unconventional = true
split_commits = false
commit_preprocessors = [
    { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/denisotree/tuitab/issues/${2}))" },
]
commit_parsers = [
    { message = "^feat", group = "Added" },
    { message = "^fix", group = "Fixed" },
    { message = "^refactor", group = "Changed" },
    { message = "^perf", group = "Changed" },
    { message = "^docs", group = "Documentation" },
    { message = "^test", skip = true },
    { message = "^chore", skip = true },
    { message = "^ci", skip = true },
    { message = "^style", skip = true },
]
filter_commits = true
tag_pattern = "v[0-9].*"
skip_tags = ""
ignore_tags = ""
topo_order = false
sort_commits = "oldest"
