Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

version_files not working#1382

AnsweredbyLee-W
WinnieS0728 asked this question inQ&A
Mar 13, 2025· 4 comments· 2 replies
Discussion options

Description

I'm using commitizen in a expo + react-native project
I do cz init and make a .cz.json like this

{"commitizen": {"name":"cz_conventional_commits","tag_format":"test-$version","version_scheme":"semver","version":"3.2.4","update_changelog_on_bump":true,"version_files": ["package.json:version","app.json:expo.version"    ]  }}

btw I selectcommitizen(default) notnpm in source of the version

then I docz commit andcz bump
everything finish
version in .cz.json did update
but version in package.json and app.json not update

I'm not sure is it a bug or not,
maybe is something I missed in configuration?
or is a syntax error?

Steps to reproduce

  1. runcz init.
  2. select
    • .cz.json
    • cz_conventional_commits(default)
    • commitizen(default)
    • Y (latest tag)
    • semver
    • n (correct tag format)
    • test-$version
    • Y (auto changelog)
    • enter (with no hooks)
  3. manually settingversion_files in .cz.json
  4. create new commit
  5. runcz bump

Current behavior

after I settingpackage.json:version andapp.json:expo.version
I think these 2 files will update the correct version
same as the version in .cz.json
but not

Desired behavior

I want these 3 files update with same and correct version

  • package.json (version)
  • app.json (expo.version)
  • .cz.json (version)

Screenshots

No response

Environment

Commitizen Version: 4.4.1
Python Version: 3.13.2 (main, Feb 4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)]
Operating System: Darwin

You must be logged in to vote
Answered by Lee-WApr 6, 2025

now my question is how to set the correct version property in version_files if version is in a nesting object.

I think you'll need to implement a customizedversion_provider. Unfortunatly, we don't have a smart enough way to specify complicated conditions inversion_files, but we welcome feature proposals 🙂

Replies: 4 comments 2 replies

Comment options

Hello
I have the same problem. Did you manage to fix it?

Edit
I managed to solve this problem by trial and error - it's a pity that it is not clearly described in the documentation, or cz bump does not have a debug option, which will indicate problematic elements.

In a situation where I have set the cz.toml configuration file in the root folder
in order for the versions in the listed files to be updated correctly, you should:

  • include the version in the cz.toml file

  • the version included in cz.toml must match the versions in the other files (in a situation where the versions in the files differ, they will not be updated)

[tool.commitizen]name ="cz_conventional_commits"tag_format ="$version"version_scheme ="semver"version ="1.6.5-b23"update_changelog_on_bump =falsemajor_version_zero =falseannotated_tag =falseversion_files = ["package.json:version","src/package.json:version","src/pyproject.toml:version"]

Another solution was to have pyproject.toml (or the appropriate manifest for configuration) in the root folder, which contained only information about the version

[tool.poetry]version ="1.6.5-b23"

cz by default searches for the location in search of the manifest file.

You must be logged in to vote
0 replies
Comment options

thank you for solving the problem.
I'm now using commitizen npm package and semantic-release

I will try this later.

You must be logged in to vote
0 replies
Comment options

Hey, sorry for the late reply.

may I know what the format of

      "package.json:version",      "app.json:expo.version"

it needs to be in the same line like

    "version": ...

if they're set in the version_file, we do not detectpackage.jsonapp.json if usingdefault provider. we only use string matching to find the line contains stringversion and the app version

You must be logged in to vote
0 replies
Comment options

hello I'm back.
sorry I've been a project deadline last week.

these is my file format.

  • .cz.json
{"commitizen": {"name":"cz_conventional_commits","tag_format":"test-$version","version_scheme":"semver","version":"3.124.0","update_changelog_on_bump":true,"version_files": ["package.json:version","app.json:expo.version"    ]  }}
  • package.json
{"name":"","version":"3.124.0","scripts": {},"dependencies": {},}
  • app.json
{"expo": {"name":"","slug":"","scheme":"","version":"3.123.0","ios": {},"android": {}}

I try the@kamilgajekdxc solution.
setting all file's with same version.

after runcz bump
package.json is update correctly.
but app.json still not.

thanks@kamilgajekdxc , set to same version is really helpful. my package.json do update.

I found the problem.
as@Lee-W said. it will find string match.
so I addexpo.version in myapp.json for testing

cz bump update "expo.version": "" to correct version and keep "expo": {"version": ""} in old version.

now my question is how to set the correct version property inversion_files if version is in a nesting object.

You must be logged in to vote
2 replies
@Lee-W
Comment options

Lee-WApr 6, 2025
Maintainer

now my question is how to set the correct version property in version_files if version is in a nesting object.

I think you'll need to implement a customizedversion_provider. Unfortunatly, we don't have a smart enough way to specify complicated conditions inversion_files, but we welcome feature proposals 🙂

Answer selected byLee-W
@WinnieS0728
Comment options

ok thanks.
I will try customize provider

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
3 participants
@WinnieS0728@Lee-W@kamilgajekdxc
Converted from issue

This discussion was converted from issue #1369 on April 06, 2025 03:53.


[8]ページ先頭

©2009-2025 Movatter.jp