Skip to content

cz bump generates broken commit when run from a subfolder. #1371

Open
@jenstroeger

Description

@jenstroeger

Description

When running cz bump --changelog from a folder other than git’s base then

  • changelog is generated in whatever folder I’m currently in instead of finding the file in the base folder, and
  • additional version_files aren’t updated at all because they’re not found.

There’s no warning or error that the additional version files weren’t found either.

If cz runs under the assumption that cwd should be the git base folder then that should be handled more gracefully, either using a warning or by finding the files correctly. As it is, running cz from some folder deeper inside of the git repo yields an unexpected and incorrect bump commit.

Steps to reproduce

Change into any subfolder in a git repo, then run cz bump --changelog.

Current behavior

  • No warnings or errors.
  • New CHANGELOG file in whichever subfolder I’m in, instead of amending the actual CHANGELOG.
  • None of the files listed in version_files are found and updated.

Desired behavior

Update the actual CHANGELOG and bump files listed in version_files.

Screenshots

No response

Environment

Commitizen Version: 4.1.0
Python Version: 3.13.2 (main, Feb  8 2025, 23:18:32) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Operating System: Darwin

Activity

Lee-W

Lee-W commented on Mar 30, 2025

@Lee-W
Member

Hi @jenstroeger , thanks for reporting this. I just verify this with the following.

cd /tmp
mkdir test-cz
cd test-cz
git init
cz init
git add .
mkdir test
cd test
touch testfile
git add .
cz c
cz bump --change

the CHANGELOG.md is generated in the test subdirectoy instead of the root

added theissue type on Mar 30, 2025
Yusin0903

Yusin0903 commented on Apr 8, 2025

@Yusin0903

Hi @Lee-W, I have reproduced the bug.
Is the right way to place the CHANGELOG to the same directory as .cz.toml?

Lee-W

Lee-W commented on Apr 9, 2025

@Lee-W
Member

Hi @Lee-W, I have reproduced the bug. Is the right way to place the CHANGELOG to the same directory as .cz.toml?

Yep, I think so. 👀

Yusin0903

Yusin0903 commented on Apr 9, 2025

@Yusin0903

@Lee-W thanks for the response!
Can I try this issue? I can do with other issue.

Lee-W

Lee-W commented on Apr 9, 2025

@Lee-W
Member

@Lee-W thanks for the response! Can I try this issue? I can do with other issue.

Sure! Thanks for helping out 🙂

jenstroeger

jenstroeger commented on Apr 13, 2025

@jenstroeger
ContributorAuthor

@Lee-W yes, you reproduce this correctly. Basically, given my package repo and no matter what the current folder I’m in, I expect that running cz updates the “real” CHANGELOG file at the root of the package/repo.

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

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Lee-W@jenstroeger@Yusin0903

      Issue actions

        `cz bump` generates broken commit when run from a subfolder. · Issue #1371 · commitizen-tools/commitizen