Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Problems with CHANGELOG generation #1620

dornech started this conversation in Ideas
Discussion options

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.

You must be logged in to vote

Replies: 4 comments 1 reply

Comment options

That's strange, which version are you running?
Check the git tags, that tags are not being reported

You must be logged in to vote
1 reply
Comment options

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 %}
Comment options

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.

You must be logged in to vote
0 replies
Comment options

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 .

You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /