-
-
Notifications
You must be signed in to change notification settings - Fork 312
feat: add parameter to changelog generation #1625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
commitizen/commands/changelog.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing comma at the end of line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I tested locally and did the change directly in GitHub ...
But thanks it is being considered at least for release 4.11, I think it is a simple change with real benefit for many.
bearomorphism
commented
Sep 21, 2025
It'd be better to add test cases related to #1620, thanks.
fix of previous change/commit regarding same topic
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## master #1625 +/- ## ========================================== + Coverage 97.33% 98.25% +0.91% ========================================== Files 42 58 +16 Lines 2104 2694 +590 ========================================== + Hits 2048 2647 +599 + Misses 56 47 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
bearomorphism
commented
Jan 15, 2026
Hi @dornech , can you help to improve the test coverage when you have a moment? Thanks!
dornech
commented
Jan 17, 2026
Hm. I am adfraid I am not experienced enough with pytest and etc to knpw what to do.
bearomorphism
commented
Jan 18, 2026
It's ok 👌
Thanks a lot for submitting the issue
Hi @dornech ,
I went through the discussion #1620 and our current codebase.
You can refer to the tests with --incremental flags in test_changelog_command.py, and provide the full template file you are using, since the existing templates in our code base cannot repro the problem you encountered.
I can continue to work on for the test. The discussion is definitely great for those people who want a # CHANGELOG level 1 header in their changelog file.
dornech
commented
Jan 18, 2026
Here you go:
{%- raw %}{% if not incremental %}
# CHANGELOG
{% endif %}{% endraw %}
{% raw %}{# Macro: Capitalize the first letter of a string only #}
{% macro capitalize_first_letter_only(sentence) %}
{{ (sentence[0] | upper) ~ sentence[1:] }}
{% endmacro %}{% endraw %}
{% raw %}{% for entry in tree %}{% endraw %}
## [{% raw %}{{ entry.version }}]({% endraw %}{{ cookiecutter.project_repo }}{% raw %}/releases/tag/{{ entry.version }}) {% if entry.date %} ({{ entry.date }}) {% endif %}{% endraw %}
{% raw %}{% for change_type, changes in entry.changes.items() %}{% endraw %}
{% raw %}{% if change_type %}{% endraw %}
### {% raw %}{{ capitalize_first_letter_only(change_type) }}{% endraw %}
{% raw %}{% endif %}{% endraw %}
{% raw %}{% for change in changes %}{% endraw %}
{% raw %}{% if change.scope %}{% endraw %}
- {% raw %}**{{ change.scope }}**: {{ capitalize_first_letter_only(change.message) }} (['{{ change.sha1[:7] }}']({% endraw %}{{ cookiecutter.project_repo }}{% raw %}/commit/{{ change.sha1 }})){% endraw %}
{% raw %}{% elif change.message %}{% endraw %}
- {% raw %}{{ capitalize_first_letter_only(change.message) }}(['{{ change.sha1[:7] }}']({% endraw %}{{ cookiecutter.project_repo }}{% raw %}/commit/{{ change.sha1 }})){% endraw %}
{% raw %}{% endif %}{% endraw %}
{% raw -%}
{% endfor %}
{% endfor %}
{% endfor %}
{% endraw -%}
You may refer to my repository https://github.com/dornech/the-hatchlor-enhanced/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/changelog_commitizen-template.md.j2
Uh oh!
There was an error while loading. Please reload this page.
... to identify incremental generation run in the jinja template.
This allows to include / exclude f. e. header lines form the current generation run to avoid multiple generation of header line(s)
Please refer to #1620