Skip to content

Bump with generating incremental changelog does not match version in previous generated changelog #297

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

Closed
xvalec01 opened this issue Nov 10, 2020 · 9 comments

Comments

@xvalec01
Copy link

xvalec01 commented Nov 10, 2020

Description

When bumping version with generating incremental changelog which was already generated from previous bump, but with clean CHANGELOG.md file, it does not found version in changelog file and says that.

No tag found to do an incremental changelog

Ending with no added new bugfix with new version in changelog.

Steps to reproduce

My pyproject.toml:

[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$major.$minor.$patch$prerelease"
version = "0.3.2"
bump_message = "bump: version $current_version → $new_version"
update_changelog_on_bump = true

My customize template is here: cz_altair.zip

  1. cz -n cz_altair bump

Tag 0.2.0 could not be found.
Possible causes:

  • version in configuration is not the current version
  • tag_format is missing, check them using 'git tag --list'

? Is this the first tag created? Yes
bump: version 0.2.0 → 0.3.0
tag to create: 0.3.0

Is this the first tag created? Yes
bump: version 0.2.0 → 0.3.0
tag to create: 0.3.0
increment detected: MINOR

Done!

  1. git commit -m "bugfix #ALT-19: New one"
  2. cz -n cz_altair bump

Current behavior

If I bump version with generating changelog (I have update_changelog_on_bump = true in my pyproject.toml file):
cz -n cz_altair bump
and my CHANGELOG.md looks like that (it was generated by previous bump run with clean CHANGELOG.md file):

## 0.3.2 (2020-11-10)

### Bug Fixes

- bugfix [#ALT-19](https://...): Hello
- bugfix [#ALT-19](https://...): Asio
- bugfix [#ALT-19](https://...): Add new line at the end of the file

### Features

- feature [#ALT-19](https://...): Something big
- feature [#ALT-19](https://...): Commitizen initial commit

and now I make new commit, which increases patch version and do cz -n cz_altair bump again, it says that:

bump: version 0.3.2 → 0.3.3
tag to create: 0.3.3
increment detected: PATCH

No tag found to do an incremental changelog

I tried let pure version on the first line in the file like 0.3.2 without any .md symbols and it matches it but generate every commit from previous changelog + one new PATCH and insert it below:

0.3.2

### Bug Fixes

- bugfix [#ALT-19](https://...): Hello
- bugfix [#ALT-19](https://...): Asio
- bugfix [#ALT-19](https://...): Add new line at the end of the file

### Features

- feature [#ALT-19](https://...): Something big
- feature [#ALT-19](https://...): Commitizen initial commit
## 0.3.3 (2020-11-10)

### Bug Fixes

- bugfix [#ALT-19](https://...): New one
- bugfix [#ALT-19](https://...): Hello
- bugfix [#ALT-19](https://...): Asio
- bugfix [#ALT-19](https://...): Add new line at the end of the file

### Features

- feature [#ALT-19](https://...): Something big
- feature [#ALT-19](https://...): Commitizen initial commit

Desired behaviour

I expect that changelog will be generated and new version will be at the start of the file (before latest version in changelog), not at the end of it .

## 0.3.3 (2020-11-10)

### Bug Fixes

- bugfix [#ALT-19](https://...): New one


## 0.3.2 (2020-11-10)

### Bug Fixes

- bugfix [#ALT-19](https://...): Hello
- bugfix [#ALT-19](https://...): Asio
- bugfix [#ALT-19](https://...): Add new line at the end of the file

### Features

- feature [#ALT-19](https://...): Something big
- feature [#ALT-19](https://...): Commitizen initial commit

Environment

  • commitizen version: 2.6.0
  • python version: 3.8.5
  • operating system: Linux Debian9
@Lee-W
Copy link
Member

Lee-W commented Nov 11, 2020

Hi, I didn't find your attached file. Could you please send it again? Also, will this error happen when you use default cz?

@xvalec01
Copy link
Author

xvalec01 commented Nov 11, 2020

I am sorry, I expected different behaviour from attaching a file. It is in Steps to reproduce or here: cz_altair.zip

Yes, now I just tried it again with default cz and bug repeats.

I now realized that in the documentation of changelog it should be only one # for version line and ## for commit types. I have in my changelog ## for version ### for change type as you can see. Can be the #ALT-19 in commit the cause? Maybe it found "H1" heading in parsing commits for changelog in type, I am just guessing this.
EDIT: It generates like this even with default cz so, my guess is probably wrong.

And I found out that in

def changelog_message_builder_hook(
        self, parsed_message: dict, commit: git.GitCommit
    ) -> dict:

parsed_message does not have change_type from commit parser. If i change it in parser to change, it is in this dict, but cz functionality does not accept change, maybe the _ in regex group is the problem.

@xvalec01
Copy link
Author

Hi, can I ask if there is any update about this issue? I know you were busy with PyCon, so I am just asking if you tried it and had the same result or whatever. Thanks a lot!

@woile
Copy link
Member

woile commented Nov 23, 2020

I took a quick look, but couldn't find if it was commitizen or your code creating the bug, so I prioritized other bugs.
My recommendation is to write tests for your regex first.
Once the regex are tested, I'd ask you to provide a project using this custom cz. Including the .cz.toml configuration, and the git folder. And an easy way to reproduce for me.
There are many potential issues that may be generating this bug.

Regards!

@xvalec01
Copy link
Author

xvalec01 commented Nov 23, 2020

I have tests for my regexes in my project.

As I said in my previous reply, I tried it even with default cz.
I removed my customization and used this config pyproject.zip and have no tags, no commits matching patterns in my git, fresh environment.

Then i just type these commands:

  1. git commit -m "feat: This is new commit"
  2. cz bump
  3. git commit -m "feat: This is last commit"
  4. cz bump

First command I have empty CHANGELOG.md
For second command it will generate:

## 0.2.0 (2020-11-23)

### Feat

- This is new commit

and fourth command just says:

bump: version 0.2.0 → 0.3.0
tag to create: 0.3.0
increment detected: MINOR

No tag found to do an incremental changelog

And no tag was created. There is no change in CHANGELOG.md.

As I mentioned how I expect it should behave:

## 0.3.0 (2020-11-23)

### Feat

- This is last commit

## 0.2.0 (2020-11-23)

### Feat

- This is new commit

Or it should behave different?

I tried even different commands:

  • cz bump --changelog
  • cz changelog --incremental

For these commands I removed option update_changelog_on_bump = true from pyproject.toml. And it just yell No tag found to do an incremental changelog

@woile
Copy link
Member

woile commented Nov 23, 2020

I reproduced your example and it just works on my side 🤔

git commit -m "feat: This is new commit"
cz bump
git commit -m "feat: This is new commit"
cz bump
$ cat CHANGELOG.md
## 0.3.0 (2020-11-23)

### Feat

- This is new commit

## 0.2.0 (2020-11-23)

### Feat

- This is new commit

what is the output of git log and git tag?

@xvalec01
Copy link
Author

git log:

commit 7edc62bc7acdb22265c3b49242ca328f5a2fac82
Author: dvalecky <dvalecky>
Date:   Mon Nov 23 14:35:01 2020 +0100

    feat: This is last commit

commit ba6853916f7d57ed8278b6d82bf72d383be0178d
Author: dvalecky <dvalecky>
Date:   Mon Nov 23 14:33:58 2020 +0100

    bump: version 0.1.0 → 0.2.0

commit de6c8a4df3e3d00730e2f37e78064f5605e6aa40
Author: dvalecky <dvalecky>
Date:   Mon Nov 23 14:32:41 2020 +0100

    feat: This is new commit

git tag:

0.2.0

@xvalec01
Copy link
Author

I just tried it on a different PC and it just works. Sorry for the inconveniences, I will try to clean my PC or python or whatever can be wrong. You can close this issue.

@woile
Copy link
Member

woile commented Nov 23, 2020

Check your git configuration, you git version and commitizen version.

In my case:

$ git version
git version 2.25.1
$ cz version
2.8.2

Feel free to open the issue again if needed.

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

No branches or pull requests

3 participants