|
| 1 | +[changelog] |
| 2 | +# template for the changelog body |
| 3 | +# https://keats.github.io/tera/docs/#introduction |
| 4 | +body = """ |
| 5 | +{% if version %}\ |
| 6 | + Version {{ version | trim_start_matches(pat="v") }} [{{ timestamp | date(format="%Y-%m-%d") }}] |
| 7 | + ------------------------------------- |
| 8 | +{% else %}\ |
| 9 | + [unreleased] |
| 10 | + ------------ |
| 11 | +{% endif %}\ |
| 12 | +{#- Features block #} |
| 13 | +{% for group, commits in commits | group_by(attribute="group") %} |
| 14 | + {% set clean_group = group | striptags | trim %} |
| 15 | + {%- if clean_group == "Features" -%} |
| 16 | + {{ clean_group | upper_first }} |
| 17 | + ~~~~~~~~ |
| 18 | + {% for commit in commits %} |
| 19 | + - {{ commit.message | split(pat="\n") | first | split(pat="]") | nth(n=1) | trim | upper_first }} |
| 20 | + {%- endfor -%} |
| 21 | + {%- endif -%} |
| 22 | +{%- endfor -%} |
| 23 | +{#- Changes block -#} |
| 24 | +{% for group, commits in commits | group_by(attribute="group") %} |
| 25 | + {% set clean_group = group | striptags | trim -%} |
| 26 | + {% if clean_group == "Backward-incompatible changes" or clean_group == "Other changes" or clean_group == "Dependencies" -%} |
| 27 | + Changes |
| 28 | + ~~~~~~~ |
| 29 | + {% break %} |
| 30 | + {% endif -%} |
| 31 | +{% endfor %} |
| 32 | +{%- for group, commits in commits | group_by(attribute="group") %} |
| 33 | + {% set clean_group = group | striptags | trim -%} |
| 34 | + {%- if clean_group == "Backward-incompatible changes" -%} |
| 35 | + {{ clean_group | upper_first }} |
| 36 | + +++++++++++++++++++++++++++++++++ |
| 37 | + {% for commit in commits %} |
| 38 | + - {{ commit.message | split(pat="\n") | first | split(pat="]") | nth(n=1) | trim | upper_first }} |
| 39 | + {%- endfor -%} |
| 40 | + {%- endif -%} |
| 41 | +{%- endfor -%} |
| 42 | +{% for group, commits in commits | group_by(attribute="group") %} |
| 43 | + {% set clean_group = group | striptags | trim %} |
| 44 | + {%- if clean_group == "Other changes" -%} |
| 45 | + {{ clean_group | upper_first }} |
| 46 | + +++++++++++++ |
| 47 | + {% for commit in commits %} |
| 48 | + - {{ commit.message | split(pat="\n") | first | split(pat="]") | nth(n=1) | trim | upper_first }} |
| 49 | + {%- endfor -%} |
| 50 | + {% endif %} |
| 51 | +{%- endfor -%} |
| 52 | +{% for group, commits in commits | group_by(attribute="group") %} |
| 53 | + {%- set clean_group = group | striptags | trim -%} |
| 54 | + {%- if clean_group == "Dependencies" -%} |
| 55 | + {{ clean_group | upper_first }} |
| 56 | + ++++++++++++ |
| 57 | + {% for commit in commits %} |
| 58 | + - {{ commit.message | split(pat="\n") | first | split(pat="]") | nth(n=1) | trim | upper_first }} |
| 59 | + {%- endfor -%} |
| 60 | + {%- endif -%} |
| 61 | +{%- endfor -%} |
| 62 | +{#- Bugfixes block #} |
| 63 | +{%- for group, commits in commits | group_by(attribute="group") -%} |
| 64 | + {% set clean_group = group | striptags | trim %} |
| 65 | + {% if clean_group == "Bugfixes" %} |
| 66 | + {{ clean_group | upper_first }} |
| 67 | + ~~~~~~~~ |
| 68 | + {% for commit in commits %} |
| 69 | + - {{ commit.message | split(pat="\n") | first | split(pat="]") | nth(n=1) | trim | upper_first }} |
| 70 | + {%- endfor -%} |
| 71 | + {% endif %} |
| 72 | +{% endfor %} |
| 73 | +""" |
| 74 | + |
| 75 | +# remove the leading and trailing space |
| 76 | +trim = true |
| 77 | + |
| 78 | +[git] |
| 79 | +# parse the commits based on https://www.conventionalcommits.org |
| 80 | +conventional_commits = false |
| 81 | +# filter out the commits that are not conventional |
| 82 | +filter_unconventional = false |
| 83 | +# process each line of a commit as an individual commit |
| 84 | +split_commits = false |
| 85 | +# an array of regex based parsers to modify commit messages prior to further processing. |
| 86 | +commit_preprocessors = [ |
| 87 | + { pattern = '#([0-9]+)', replace = '`#$1 <https://github.com/#REPO#/issues/$1>`_' }, |
| 88 | +] |
| 89 | + |
| 90 | +# regex for parsing and grouping commits |
| 91 | +commit_parsers = [ |
| 92 | + # Any commits with [skip changelog] in their message will be ignored. |
| 93 | + { message = "\\[skip changelog\\]", skip = true }, |
| 94 | + # Regex for features, e.g., '[feature]' or '[feature:api]' |
| 95 | + { message = "^(\\[feature(:[a-zA-Z0-9_-]+)?\\])", group = "<!-- 0 -->Features", strip = "message" }, |
| 96 | + # Regex for backward-incompatible changes, e.g., '[change!]' or '[change:db!]' |
| 97 | + { message = "^(\\[change(:[a-zA-Z0-9_-]+)?!\\])", group = "<!-- 1 -->Backward-incompatible changes", strip = "message" }, |
| 98 | + # Regex for regular changes, e.g., '[change]' or '[change:ui]' |
| 99 | + { message = "^(\\[change(:[a-zA-Z0-9_-]+)?\\])", group = "<!-- 2 -->Other changes", strip = "message" }, |
| 100 | + # Regex for dependency updates, e.g., '[deps]' or '[deps:npm]' |
| 101 | + { message = "^(\\[deps(:[a-zA-Z0-9_-]+)?\\])", group = "<!-- 3 -->Dependencies", strip = "message" }, |
| 102 | + # Regex for bugfixes, e.g., '[fix]' or '[fix:tests]' |
| 103 | + { message = "^(\\[fix(:[a-zA-Z0-9_-]+)?\\])", group = "<!-- 4 -->Bugfixes", strip = "message" }, |
| 104 | +] |
| 105 | + |
| 106 | +# protect breaking changes from being skipped due to matching a skipping commit_parser |
| 107 | +protect_breaking_commits = false |
| 108 | +# filter out the commits that are not matched by commit parsers |
| 109 | +filter_commits = false |
| 110 | +# sort the tags topologically |
| 111 | +topo_order = false |
| 112 | +# sort the commits inside sections by oldest/newest order |
| 113 | +sort_commits = "newest" |
0 commit comments