-
-
Notifications
You must be signed in to change notification settings - Fork 301
-
I am trying to set-up commitizen as my standard toolchain for commiting and publishing. I like it pretty much as it is a handy all-in solution. However, I have some trouble setting ub the changelog generation. I encounter the problem, that the header line is duplicated. Does anybody experience this issue and knows how to resolve ?
Another problem is that generated changelog runs into an error with the trailing-whitespace check. However, this can be overcome with retry option even this is still somewhat weird.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 4 comments 1 reply
-
That's strange, which version are you running?
Check the git tags, that tags are not being reported
Beta Was this translation helpful? Give feedback.
All reactions
-
Latest version 4.9.1 The issue seems to occur when I do a cz bump
with integrated changelog update (i. e. update_changelog_on_bump = true
in my pyproject.toml).
When I do a cz changelog
thereafter, it is being fixed again.
Here is my Jinja template (sightly modified to include the commit tags on GitHub)
# CHANGELOG
{# MACRO: Capitalize the first letter of a string only #}
{% macro capitalize_first_letter_only(sentence) %}
{{ (sentence[0] | upper) ~ sentence[1:] }}
{% endmacro %}
{% for entry in tree %}
## [{{ entry.version }}](https://github.com/dornech/pytestdornech/releases/tag/{{ entry.version }}) {% if entry.date %}({{ entry.date }}){% endif %}
{% for change_type, changes in entry.changes.items() %}
{% if change_type %}
### {{ capitalize_first_letter_only(change_type) }}
{% endif %}
{% for change in changes %}
{% if change.scope %}
- **{{ change.scope }}**: {{ capitalize_first_letter_only(change.message) }} (['{{ change.sha1[:7] }}'](https://github.com/dornech/pytestdornech/commit/{{ change.sha1 }}))
{% elif change.message %}
- {{ capitalize_first_letter_only(change.message) }}(['{{ change.sha1[:7] }}'](https://github.com/dornech/pytestdornech/commit/{{ change.sha1 }}))
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
Beta Was this translation helpful? Give feedback.
All reactions
-
I did some further investigations. I wonder if this is causes by the difference between complete new changelog and incremental.
If doing cz changelog
, then it is implicitly done as a complete new changelog, correct ?
If I do a cz bump
with update_changelog_on_bump = true
(as I do) then this implicitly done as incremental changelog, correct?
This would explain the behaviour as described.
However, I think it is desirable to fix that to allow to maintain a headline in the template without running into the trouble this headline to be duplicated during incremental changelog updates.
Beta Was this translation helpful? Give feedback.
All reactions
-
I think I am right :-)
To overcome I guess an easy improvement would be to provide the changleog generation mode as additional variable. This would allow to control in the jinja template if an headline is generated or not. For incremental changlogs then the headerlines (or footer lines if desired) would not be generated.
Another option: changelog_incremental
is not automatically set to true for cz bump
.
Beta Was this translation helpful? Give feedback.
All reactions
-
So, tried it.
One additional line (inserted between lines 247 and 248 in /commitizen/commands/changelog.py
changelog_out = changelog.render_changelog(
tree,
self.cz.template_loader,
self.template,
incremental=self.incremental, # <-- inserted line here
**{
**self.cz.template_extras,
**self.config.settings["extras"],
**self.extras,
},
).lstrip("\n")
... and following change in the template
{% if not incremental %}
# CHANGELOG
{% endif %}
{# MACRO: Capitalize the first letter of a string only #}
...
does the job.
Beta Was this translation helpful? Give feedback.