1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
{# TOWNCRIER TEMPLATE #}
*({{ versiondata.date }})*
{% for section, _ in sections.items() %}
{% set underline = underlines[0] %}{% if section %}{{section}}
{{ underline * section|length }}{% set underline = underlines[1] %}
{% endif %}
{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section]%}
{{ definitions[category]['name'] }}
{{ underline * definitions[category]['name']|length }}
{% if definitions[category]['showcontent'] %}
{% for text, change_note_refs in sections[section][category].items() %}
- {{ text }}
{{- '\n' * 2 -}}
{#-
NOTE: Replacing 'e' with 'f' is a hack that prevents Jinja's `int`
NOTE: filter internal implementation from treating the input as an
NOTE: infinite float when it looks like a scientific notation (with a
NOTE: single 'e' char in between digits), raising an `OverflowError`,
NOTE: subsequently. 'f' is still a hex letter so it won't affect the
NOTE: check for whether it's a (short or long) commit hash or not.
Ref: https://github.com/pallets/jinja/issues/1921
-#}
{%-
set pr_issue_numbers = change_note_refs
| map('lower')
| map('replace', 'e', 'f')
| map('int', default=None)
| select('integer')
| map('string')
| list
-%}
{%- set arbitrary_refs = [] -%}
{%- set commit_refs = [] -%}
{%- with -%}
{%- set commit_ref_candidates = change_note_refs | reject('in', pr_issue_numbers) -%}
{%- for cf in commit_ref_candidates -%}
{%- if cf | length in (7, 8, 40) and cf | int(default=None, base=16) is not none -%}
{%- set _ = commit_refs.append(cf) -%}
{%- else -%}
{%- set _ = arbitrary_refs.append(cf) -%}
{%- endif -%}
{%- endfor -%}
{%- endwith -%}
{% if pr_issue_numbers %}
*Related issues and pull requests on GitHub:*
:issue:`{{ pr_issue_numbers | join('`, :issue:`') }}`.
{{- '\n' * 2 -}}
{%- endif -%}
{% if commit_refs %}
*Related commits on GitHub:*
:commit:`{{ commit_refs | join('`, :commit:`') }}`.
{{- '\n' * 2 -}}
{%- endif -%}
{% if arbitrary_refs %}
*Unlinked references:*
{{ arbitrary_refs | join(', ') }}.
{{- '\n' * 2 -}}
{%- endif -%}
{% endfor %}
{% else %}
- {{ sections[section][category]['']|join(', ') }}
{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes.
{% else %}
{% endif %}
{% endfor %}
{% else %}
No significant changes.
{% endif %}
{% endfor %}
----
{{ '\n' * 2 }}
|