[remote.github]
owner = "sermuns"
repo = "stil"

[bump]
features_always_bump_minor = false
breaking_always_bump_major = false

[changelog]
header = """
# Changelog\n
"""
body = """
{% if version %}\
    {% if previous.version %}\
        ## [{{ version }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
    {% else %}\
        ## [{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }}
    {% endif %}\
{% else %}\
    ## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | striptags | trim | upper_first }}

    {% for commit in commits
    | filter(attribute="scope")
    | sort(attribute="scope") -%}
        {% if commit.scope -%}
    - {{self::commit(commit=commit)}}\
        {% endif -%}
    {% endfor -%}
    {% for commit in commits -%}
        {% if commit.scope -%}
        {% else -%}
    - {{self::commit(commit=commit)}}\
        {% endif -%}
    {% endfor -%}
{% endfor -%}

{% macro commit(commit) -%}
{% if commit.scope %}**({{commit.scope}})** {% endif -%}
{% if commit.breaking %}**breaking** {% endif -%}
{{ commit.message | split(pat="\n") | first | trim }} by\
{% if commit.remote.username %} @{{commit.remote.username}}\
{% else %} {{commit.author.name}}{% endif %} in\
{% if commit.remote.pr_number %} [#{{ commit.remote.pr_number }}]($REPO/pull/{{ commit.remote.pr_number }})\
{% else %} [{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})\
{%- endif %}
{% endmacro commit -%}
"""

postprocessors = [
  { pattern = '\$REPO', replace = "https://github.com/sermuns/stil" },
]
