Skip to content

Commit fbf067c

Browse files
author
Matéo Fernandez
committed
docs(changelog): use macros from git-cliff to print commit links in changelog
1 parent 82736ce commit fbf067c

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

cliff.toml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,35 @@ header = """
1313
# template for the changelog body
1414
# https://keats.github.io/tera/docs/#introduction
1515
body = """
16+
{%- macro remote_url() -%}
17+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
18+
{%- endmacro -%}
19+
20+
{% macro print_commit(commit) -%}
21+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
22+
{% if commit.breaking %}[**breaking**] {% endif %}\
23+
{{ commit.message | upper_first }} - \
24+
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
25+
{% endmacro -%}
26+
1627
{% if version %}\
1728
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
1829
{% else %}\
1930
## [unreleased]
2031
{% endif %}\
2132
{% for group, commits in commits | group_by(attribute="group") %}
2233
### {{ group | striptags | trim | upper_first }}
34+
{% for commit in commits
35+
| filter(attribute="scope")
36+
| sort(attribute="scope") %}
37+
{{ self::print_commit(commit=commit) }}
38+
{%- endfor %}
2339
{% for commit in commits %}
24-
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
25-
{% if commit.breaking %}[**breaking**] {% endif %}\
26-
{{ commit.message | upper_first }}\
27-
{% endfor %}
28-
{% endfor %}\n
40+
{%- if not commit.scope -%}
41+
{{ self::print_commit(commit=commit) }}
42+
{% endif -%}
43+
{% endfor -%}
44+
{% endfor -%}\n
2945
{%- if github -%}
3046
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
3147
## New Contributors

0 commit comments

Comments
 (0)