Skip to content

Conversation

@dornech
Copy link

@dornech dornech commented Sep 20, 2025

... 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

tree,
self.cz.template_loader,
self.template,
incremental=self.incremental
Copy link
Collaborator

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.

Copy link
Author

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
Copy link
Collaborator

It'd be better to add test cases related to #1620, thanks.

@Lee-W Lee-W added this to the 4.11.0 milestone Sep 21, 2025
fix of previous change/commit regarding same topic
@codecov
Copy link

codecov bot commented Sep 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.25%. Comparing base (120d514) to head (2facaca).
⚠️ Report is 948 commits behind head on master.

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     
Flag Coverage Δ
unittests 98.25% <ø> (+0.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bearomorphism
Copy link
Collaborator

Hi @dornech , can you help to improve the test coverage when you have a moment? Thanks!

@dornech
Copy link
Author

dornech commented Jan 17, 2026

Hm. I am adfraid I am not experienced enough with pytest and etc to knpw what to do.

@bearomorphism
Copy link
Collaborator

It's ok 👌
Thanks a lot for submitting the issue

@bearomorphism
Copy link
Collaborator

bearomorphism commented Jan 18, 2026

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants