Repository navigation
changelog does not include body or footer information #746
Description
Activity
It is possible to add the body and footer information by customizing the config_parser regex and the template.
For example, set up a
cz.yamlfile with something like this:--- commitizen: customize: commit_parser: ^((?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?|\w+!):\s(?P<subject>[^\n]*)(?P<body>(?:\n(?!Refs:|:\s#)[^\n]*)*)(?:\n(?P<footer>(?:Refs:[\s\S]*)?))?$ name: cz_customize tag_format: v$version update_changelog_on_bump: true version_provider: npm version_scheme: semver template: CHANGELOG.md.j2The
commit_parserwill parse your commit, and make the capture groups available to your formatter. In the regex string above, we're getting a section after the subject and labeling it "body", and getting any content that starts "Refs: " and labeling it footer.You can then create a template
CHANGELOG.md.j2like this:{% for entry in tree %} {% set entry_title -%} {{ entry.version }}{% if entry.date %} ({{ entry.date }}){% endif -%} {%- endset %} {{ entry_title }} {{ "=" * entry_title|length }} {% for change_key, changes in entry.changes.items() %} {% if change_key %} {{ change_key }} {{ "-" * change_key|length }} {% endif %} {% for change in changes %} {% if change.footer %} {% set ticket = change.footer.split('#')[1] %} {% endif %} {% set ticket_link = "[[" + ticket + "](https://blah.atlassian.net/browse/" + ticket + ")] " if ticket else "" %} {% set commit_link = "[" + change.sha1[:7] + "](" + change.sha1 + ")" %} {% set scope = "**" + change.scope + "**: " if change.scope else "" %} - {{ ticket_link }}{{ scope }}{{ change.subject }} {{commit_link}} {% if change.body %} {% set lines = change.body.split('\n') %} {% for line in lines %} {% set stripped_line = line.strip() -%} {% if stripped_line.startswith('-') %} {{ stripped_line }} {% elif stripped_line %} - {{ stripped_line }} {% endif %} {% endfor %} {% endif %} {% endfor %} {% endfor %} {% endfor %}Which will use the capture groups
subjectbodyandfooterfrom thecommit_parseris thecz.yaml.Adjust the regex according to your commit formatting:
Reacted by Dominic Bortmes and Tuukka MustonenTriage from #1964: Body and footer aren't included by default — only the title is captured by
cz_conventional_commits's defaultcommit_parser. To include them, you can write a customchangelog_message_builder_hookor overridecommit_parserto capture body groups. Suggesting we relabel astype: feature(changelog template support for body/footer) or close as documented limitation.Verification update (re #1964)
Reproduced against current master (4.15.1):
Made a commit with the form
feat: add new feature This is the body explaining the feature in detail. It spans multiple lines. Refs: TICKET-123 Reviewed-by: someonecz changelog --dry-runoutput:## Unreleased ### Feat - add new feature
The body and footer are dropped — only the title's subject (after the type) appears.
Verdict: STILL VALID as documented behaviour, but I'd argue this is a reasonable feature gap rather than a bug.
The default
commit_parserincz_conventional_commitsonly captures the type, scope, and subject. To include body/footer, users currently need to:- Override
commit_parserwith a regex that capturesbody/footernamed groups, AND - Use a custom Jinja
template(orchangelog_message_builder_hook) that renders those groups.
A small UX win would be to add a top-level config option like
changelog_include_body = truethat automatically swaps in a richer parser + template, so non-Python users don't need to write a hook just to render full commit info.Suggesting we relabel as
type: featureand either implement the convenience flag, or close with a docs link to the customization guide.- Override
Description
When generating a changelog where commits contain conventional commits, the body (the extended commit information) along with the footer information (ticket references information, etc.) is not written to the output file.
Steps to reproduce
cz changelog
Current behavior
Commits that have body and footer information, have this information missing from the changelog.
Desired behavior
Commits that have body and footer information, would have this information shown in the changelog.
Screenshots
No response
Environment