|
| 1 | +{% from 'macros.md.j2' import apply_alphabetical_ordering_by_brk_descriptions |
| 2 | +%}{% from 'macros.md.j2' import apply_alphabetical_ordering_by_descriptions |
| 3 | +%}{% from 'macros.md.j2' import apply_alphabetical_ordering_by_release_notices |
| 4 | +%}{% from 'macros.md.j2' import format_breaking_changes_description, format_commit_summary_line |
| 5 | +%}{% from 'macros.md.j2' import format_release_notice |
| 6 | +%}{# |
| 7 | +EXAMPLE: |
| 8 | +
|
| 9 | +### Features |
| 10 | +
|
| 11 | +- Add new feature ([#10](https://domain.com/namespace/repo/pull/10), |
| 12 | + [`abcdef0`](https://domain.com/namespace/repo/commit/HASH)) |
| 13 | +
|
| 14 | +- **scope**: Add new feature ([`abcdef0`](https://domain.com/namespace/repo/commit/HASH)) |
| 15 | +
|
| 16 | +### Bug Fixes |
| 17 | +
|
| 18 | +- Fix bug ([#11](https://domain.com/namespace/repo/pull/11), |
| 19 | + [`abcdef1`](https://domain.com/namespace/repo/commit/HASH)) |
| 20 | +
|
| 21 | +### Breaking Changes |
| 22 | +
|
| 23 | +- With the change _____, the change causes ___ effect. Ultimately, this section |
| 24 | + it is a more detailed description of the breaking change. With an optional |
| 25 | + scope prefix like the commit messages above. |
| 26 | +
|
| 27 | +- **scope**: this breaking change has a scope to identify the part of the code that |
| 28 | + this breaking change applies to for better context. |
| 29 | +
|
| 30 | +### Additional Release Information |
| 31 | +
|
| 32 | +- This is a release note that provides additional information about the release |
| 33 | + that is not a breaking change or a feature/bug fix. |
| 34 | +
|
| 35 | +- **scope**: this release note has a scope to identify the part of the code that |
| 36 | + this release note applies to for better context. |
| 37 | +
|
| 38 | +#}{% set max_line_width = max_line_width | default(100) |
| 39 | +%}{% set hanging_indent = hanging_indent | default(2) |
| 40 | +%}{# |
| 41 | +#}{% for type_, commits in commit_objects if type_ != "unknown" |
| 42 | +%}{# PREPROCESS COMMITS (order by description & format description line) |
| 43 | +#}{% set ns = namespace(commits=commits) |
| 44 | +%}{% set _ = apply_alphabetical_ordering_by_descriptions(ns) |
| 45 | +%}{# |
| 46 | +#}{% set commit_descriptions = [] |
| 47 | +%}{# |
| 48 | +#}{% for commit in ns.commits |
| 49 | +%}{# # Update the first line with reference links and if commit description |
| 50 | + # has more than one line, add the rest of the lines |
| 51 | + # NOTE: This is specifically to make sure to not hide contents |
| 52 | + # of squash commits (until parse support is added) |
| 53 | +#}{% set description = "- %s" | format(format_commit_summary_line(commit)) |
| 54 | +%}{% if commit.descriptions | length > 1 |
| 55 | +%}{% set description = "%s\n\n%s" | format( |
| 56 | + description, commit.descriptions[1:] | join("\n\n") |
| 57 | + ) |
| 58 | +%}{% endif |
| 59 | +%}{% set description = description | autofit_text_width(max_line_width, hanging_indent) |
| 60 | +%}{% set _ = commit_descriptions.append(description) |
| 61 | +%}{% endfor |
| 62 | +%}{# |
| 63 | + # # PRINT SECTION (header & commits) |
| 64 | +#}{% if commit_descriptions | length > 0 |
| 65 | +%}{{ "\n" |
| 66 | +}}{{ "### %s\n" | format(type_ | title) |
| 67 | +}}{{ "\n" |
| 68 | +}}{{ "%s\n" | format(commit_descriptions | unique | join("\n\n")) |
| 69 | +}}{% endif |
| 70 | +%}{% endfor |
| 71 | +%}{# |
| 72 | + # Determine if there are any breaking change commits by filtering the list by breaking descriptions |
| 73 | + # commit_objects is a list of tuples [("Features", [ParsedCommit(), ...]), ("Bug Fixes", [ParsedCommit(), ...])] |
| 74 | + # HOW: Filter out breaking change commits that have no breaking descriptions |
| 75 | + # 1. Re-map the list to only the list of commits under the breaking category from the list of tuples |
| 76 | + # 2. Peel off the outer list to get a list of ParsedCommit objects |
| 77 | + # 3. Filter the list of ParsedCommits to only those with a breaking description |
| 78 | +#}{% set breaking_commits = commit_objects | map(attribute="1.0") |
| 79 | +%}{% set breaking_commits = breaking_commits | rejectattr("error", "defined") | selectattr("breaking_descriptions.0") | list |
| 80 | +%}{# |
| 81 | +#}{% if breaking_commits | length > 0 |
| 82 | +%}{# PREPROCESS COMMITS |
| 83 | +#}{% set brk_ns = namespace(commits=breaking_commits) |
| 84 | +%}{% set _ = apply_alphabetical_ordering_by_brk_descriptions(brk_ns) |
| 85 | +%}{# |
| 86 | +#}{% set brking_descriptions = [] |
| 87 | +%}{# |
| 88 | +#}{% for commit in brk_ns.commits |
| 89 | +%}{% set full_description = "- %s" | format( |
| 90 | + format_breaking_changes_description(commit).split("\n\n") | join("\n\n- ") |
| 91 | + ) |
| 92 | +%}{% set _ = brking_descriptions.append( |
| 93 | + full_description | autofit_text_width(max_line_width, hanging_indent) |
| 94 | + ) |
| 95 | +%}{% endfor |
| 96 | +%}{# |
| 97 | + # # PRINT BREAKING CHANGE DESCRIPTIONS (header & descriptions) |
| 98 | +#}{{ "\n" |
| 99 | +}}{{ "### Breaking Changes\n" |
| 100 | +}}{{ |
| 101 | + "\n%s\n" | format(brking_descriptions | unique | join("\n\n")) |
| 102 | +}}{# |
| 103 | +#}{% endif |
| 104 | +%}{# |
| 105 | + # Determine if there are any commits with release notice information by filtering the list by release_notices |
| 106 | + # commit_objects is a list of tuples [("Features", [ParsedCommit(), ...]), ("Bug Fixes", [ParsedCommit(), ...])] |
| 107 | + # HOW: Filter out commits that have no release notices |
| 108 | + # 1. Re-map the list to only the list of commits from the list of tuples |
| 109 | + # 2. Peel off the outer list to get a list of ParsedCommit objects |
| 110 | + # 3. Filter the list of ParsedCommits to only those with a release notice |
| 111 | +#}{% set notice_commits = commit_objects | map(attribute="1.0") |
| 112 | +%}{% set notice_commits = notice_commits | rejectattr("error", "defined") | selectattr("release_notices.0") | list |
| 113 | +%}{# |
| 114 | +#}{% if notice_commits | length > 0 |
| 115 | +%}{# PREPROCESS COMMITS |
| 116 | +#}{% set notice_ns = namespace(commits=notice_commits) |
| 117 | +%}{% set _ = apply_alphabetical_ordering_by_release_notices(notice_ns) |
| 118 | +%}{# |
| 119 | +#}{% set release_notices = [] |
| 120 | +%}{# |
| 121 | +#}{% for commit in notice_ns.commits |
| 122 | +%}{% set full_description = "- %s" | format( |
| 123 | + format_release_notice(commit).split("\n\n") | join("\n\n- ") |
| 124 | + ) |
| 125 | +%}{% set _ = release_notices.append( |
| 126 | + full_description | autofit_text_width(max_line_width, hanging_indent) |
| 127 | + ) |
| 128 | +%}{% endfor |
| 129 | +%}{# |
| 130 | + # # PRINT RELEASE NOTICE INFORMATION (header & descriptions) |
| 131 | +#}{{ "\n" |
| 132 | +}}{{ "### Additional Release Information\n" |
| 133 | +}}{{ |
| 134 | + "\n%s\n" | format(release_notices | unique | join("\n\n")) |
| 135 | +}}{# |
| 136 | +#}{% endif |
| 137 | +%} |
0 commit comments