Incremental changelog fails without tags
Description
I wanted to open, discuss, and track the issue here, based on our previous conversation in issue https://github.com/jenstroeger/python-package-template/issues/301. In short, running cz changelog --incremental on a repo without tags may fail with
> git tag
> cz changelog --dry-run --incremental --unreleased-version "Release Notes"
No tag found to do an incremental changelog
However, after some more investigation I think that cz may behave correctly.
Steps to reproduce
First, set up a new git repository:
> mkdir test-cz
> cd test-cz/
test-cz > git init .
test-cz > git commit --allow-empty --message "chore: some work"
[master (root-commit) 05cd66f] chore: some work
Note that the repository has no tags:
> git tag
>
Next, set up the Python virtual environment and commitizen:
test-cz > python -m venv .venv
test-cz > . .venv/bin/activate
(.venv) test-cz > pip install --upgrade pip commitizen
No need to set up a pyproject.toml or other configuration.
Now run cz which works as expected:
(.venv) test-cz > cz changelog --dry-run --incremental --unreleased-version "Release Notes"
## Release Notes (2022-09-05)
This also works with an empty existing CHANGELOG.md file:
(.venv) test-cz > echo "" > CHANGELOG.md
(.venv) test-cz > cz changelog --dry-run --incremental --unreleased-version "Release Notes"
## Release Notes (2022-09-05)
However, letβs add a version to the existing CHANGELOG.md:
(.venv) test-cz > cat CHANGELOG.md
## v1.0.0
(.venv) test-cz > cz changelog --dry-run --incremental --unreleased-version "Release Notes"
No tag found to do an incremental changelog
Current behavior
In a repository without tags but a CHANGELOG.md with tags, cz changelog --incremental fails with error
No tag found to do an incremental changelog
Desired behavior
Considering the inconsistency between repository tags and CHANGELOG.md the current behavior is probably ok.
Screenshots
No response
Environment
Commitizen Version: 2.32.2
Python Version: 3.9.13 (main, May 21 2022, 02:35:37)
[Clang 10.0.1 (clang-1001.0.46.4)]
Operating System: Darwin
Makes sense, PR are welcome!
Looks more like a feature to me π€ as you said cz may behave correctly.. Thus, I'll relabel this issue as feature. we could discuss more if you deem otherwise π
We could discuss more if you deem otherwise π
I think we should. The current behavior is probably correct, but maybe the message could be improved. Maybe it makes sense for cz to run a consistency check between repo tags and CHANGELOG before taking any action.