commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

2nd git.commit error: "On branch main nothing to commit, working tree clean"

Open loelkes opened this issue 7 months ago • 4 comments

Description

Commitizen fails if version_provider is set to scm and no files are changed (no changelog, no version number in files) a version bump

Steps to reproduce

  1. Create en empty repository with git init test and change into it cd test
  2. Add a configuration cz.toml
[tool.commitizen]
version_provider = "scm"
  1. Commit it with git add cz.toml and cz commit
  2. Run cz bump
bump: version 0.0.0 → 0.0.1
tag to create: 0.0.1
increment detected: PATCH

[main 16e057b] bump: version 0.0.0 → 0.0.1
 1 file changed, 1 insertion(+), 1 deletion(-)

Done!
  1. Add another file / make another changer with touch foobar, git add foobar and cz commit
  2. Run cz bump
bump: version 0.0.1 → 0.0.2
tag to create: 0.0.2
increment detected: PATCH

2nd git.commit error: "On branch main
nothing to commit, working tree clean
"

If I run cz bump --changelog the second time, there is no error.

Current behavior

cz bump fails if no changes (updated changelog, version number in files) are made during a version bump.

Desired behavior

cz bump should not fail if no changes (updated changelog, version number in files) are made during a version bump.

Screenshots

No response

Environment

Commitizen Version: 4.8.2 Python Version: 3.13.4 (main, Jun 3 2025, 15:34:24) [Clang 17.0.0 (clang-1700.0.13.3)] Operating System: Darwin

loelkes avatar Jun 10 '25 09:06 loelkes

With update_changelog_on_bump = true, it works fine, but this is a valid bug. Thanks for reporting!

Lee-W avatar Jun 10 '25 13:06 Lee-W

This came to light while building a workaround for https://github.com/commitizen-tools/commitizen/issues/883

Since I can't use the changelog due to this bug I run cz bump without --changelog / update_changelog_on_bump = true

loelkes avatar Jun 10 '25 14:06 loelkes

There's a PR open supposed to fix this https://github.com/commitizen-tools/commitizen/pull/996

woile avatar Jun 10 '25 14:06 woile

oh.... I'll see whether I can make it merged in the next release

Lee-W avatar Jun 11 '25 01:06 Lee-W