question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion on check-consistency

See original GitHub issue

Description

Hi, I’ve doubt on how check-consistency flag works.

Steps to reproduce

  1. have a project managed with poetry, with a pyproject.toml like the following
[tool.poetry]
    name = "cool_proj"
    version = "2.5.7"    <<<< this is mandatory for poetry to make the package
...
[tool.commitizen]
    name = "cz_conventional_commits"
    version = "2.5.2"   <<<< this is mandatory for commitizen
    version_files = [
        "cool_proj/__init__.py:__version__",
        "pyproject.toml:version"
    ]

and __init__.py contains

__version__ = "2.5.2"
  1. run poetry run cz bump --check-consistency

Current behavior

the command works, it prints on stdout

Bump version: 2.5.2 -> 2.5.3        <<< it takes the value from commitizen's toml section
tag to create: 2.5.3

Desired behavior

the expected could be a warning about version not consistent, because at least content of __init__.py differ from the expected (the one into commitizen’s toml section).

looking at implementation, also the regex usage has major drawback in this kind of setup, because the regex surely find commitizen’s “version” attribute, but it can miss the poetry’s one, creating package with wrong number (it’s taken from poetry section).

Screenshots

No response

Environment

  • commitizen 2.34.0
  • python 3.9.13
  • windows 11

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
woilecommented, Sep 26, 2022

I agree with @Lee-W , I think the current pattern is flexible enough. If you go on the route to support each extension (which is an endless route), it will become a huge burden to maintain. We’d like the tool to remain as general as possible and support any file. A possible regex that solves this could be:

version_files = [
        "cool_proj/__init__.py:__version__",
        "pyproject.toml:\[tool\.poetry\][.\s\D]*^version"
    ]

Which would match this toml properly:

[tool.poetry]
name = "foo"
version = "1.2.3"

[tool.commitizen]
version = "1.2.3"

In my experience most of the time doing ^version has been enough, and I haven’t used check-consistency much.

I do agree the check-consistency is problematic for this case. But in a way if you have commitizen and poetry under the same toml and your regex is pyproject.toml:^version, the regex pattern will pick any of the present words, because that’s what we are telling it to do. I think one option is to use .cz.toml or go for a stronger regex.

0reactions
Lee-Wcommented, Sep 26, 2022

This sounds to be a great solution. But I’m a bit worried about the maintenance cost and inconsistency between each format. @woile What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

GameObject does not reference component MonoBehaviour ...
CheckConsistency : GameObject does not reference component MonoBehaviour. Fixing. Discussion in 'Editor & General Support' started by ...
Read more >
checkConsistency | Apple Developer Documentation
Discussion. The value for this key is an NSNumber object containing a Boolean value. The default value is false . If you set...
Read more >
Warning: SendMessage cannot be called during Awake ...
SendMessage cannot be called during Awake, CheckConsistency, or OnValidate UnityEngine.GameObject:AddComponent<DG.Tweening.Core.
Read more >
"Check consistency" | NI Community Forum - Native Instruments
Folks, I've analysed some music in Mixed In Key. You need to run "Check consistency" in Traktor so the keys display.
Read more >
Re: Flow Check consistency issue, most objects unchecked
Sign up to take part. Registered users can ask their own questions, contribute to discussions, and be part of the Community! Sign Up....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found