{% for entry in tree %}

# {{ entry.version }}{% if entry.date %} ({{ entry.date }}){% endif %}

{% for change_key, changes in entry.changes.items() %}

{% set change_key_map = {
  'BREAKING CHANGE': '🪓 Breaking changes',
  'doc': '📝 Documentation',
  'feat': '💫 New features',
  'fix': '🐛 Bug Fixes',
  'test': '🛡 Tests',
  'rf': '🏠 Refactorings',
  'perf': '🚀 Performance improvements',
} %}
{% if change_key %}
## {{ change_key_map.get(change_key, change_key) }}
{% endif %}
{% set scopemap = {
  'changelog': 'Changelog',
  'contributing': 'Contributing guide',
  'helpers': 'Helpers',
  'sphinx': 'Rendered documentation',
  'typeannotation': 'Type annotation',
} %}

{# no-scope changes #}
{% for change in changes | rejectattr("scope") %}
- {{ change.message }} [[{{ change.sha1 | truncate(8, true, '') }}]](https://github.com/datalad/datasalad/commit/{{ change.sha1 | truncate(8, true, '') }})
{% endfor %}
{# scoped changes #}
{% for scope, scope_changes in changes | selectattr("scope") | groupby("scope") %}
- {{ scopemap.get(scope, scope) }}:
{% for change in scope_changes %}
  - {{ change.message }} [[{{ change.sha1 | truncate(8, true, '') }}]](https://github.com/datalad/datasalad/commit/{{ change.sha1 | truncate(8, true, '') }})
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
