Skip to content

Incremental changelog fails without tags #574

Open
@jenstroeger

Description

@jenstroeger

Description

I wanted to open, discuss, and track the issue here, based on our previous conversation in issue jenstroeger/python-package-template#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions